帮助我理解以下与 AsyncFileUpload 控件相关的 javascript
在我当前的项目中,我使用了 AJAX 控件工具包中的 AsyncFileUpload 控件。在异步文件上传部分工作后,我需要过滤文件类型,以便用户只能上传图像文件。我在网上找到了以下代码,它运行良好:
function uploadStarted(sender, args) {
var filename = args.get_fileName();
var filext = filename.substring(filename.lastIndexOf(".") + 1);
if (filext == "jpg" || filext == "jpeg" || filext == "gif" || filext == "bmp") {
return true;
}
else
{
// force uploading cancel
args.set_cancel(true);
// set reason of cancel
args.set_errorMessage("Invalid File Format Selected");
return false;
}
}
问题是:我不明白这个 javascript。 args 参数的类型是什么? “get_fileName()”、“set_cancel()”等方法在哪里定义?我访问了 AsyncFileUpload 控件的主页,但找不到任何有关“args”的文档。
有人可以帮我解释一下这个Javascript吗?谢谢
in my current project I used a AsyncFileUpload control from AJAX Control Toolkits. After I got the async file upload part working, I needed to filter the file type so users can only upload image files. I found the following code off web and it worked well:
function uploadStarted(sender, args) {
var filename = args.get_fileName();
var filext = filename.substring(filename.lastIndexOf(".") + 1);
if (filext == "jpg" || filext == "jpeg" || filext == "gif" || filext == "bmp") {
return true;
}
else
{
// force uploading cancel
args.set_cancel(true);
// set reason of cancel
args.set_errorMessage("Invalid File Format Selected");
return false;
}
}
The problem is : I don't understand this javascript. What is the type of args parameter? Where are the methods such as "get_fileName()", "set_cancel()" defined? I went to the homepage of the AsyncFileUpload control but couldn't find any documentation regarding the "args".
Can someone help me out explaining this Javascript? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我可以回答我自己的问题
第一个参数标识触发事件的对象,而第二个参数提供有关正在上传的文件的信息。事实上,它包含使用上面演示的 get_abc() 语法访问的五个有用属性。
有关更多详细信息,请参阅本文:
http://p2p .wrox.com/content/blogs/danm/enter-asyncfileupload-control
I think I can answer my own question
The first parameter identifies the object that fired the event, while the second provides information on the file being uploaded. In fact, it contains five useful properties accessed using the get_abc() syntax demonstrated above.
For more details refer to this article:
http://p2p.wrox.com/content/blogs/danm/enter-asyncfileupload-control