uploadify插件的确是个好东西,但是对于像我这样才接触的人来说,确实被坑惨了。
本来准备将uploadify用在ASP.NET MVC中试试,可是试了N久,没试个所以然来,这还是主要怪自己对MVC不熟悉。好吧,MVC 不行 Web Form 总该可以吧!
因为自己今天才接触这个插件,所以更不就不清楚怎么用,官网上面的又是一个PHP的demo。。。确实没有办法,在网上搜了很久,才知道结合一般处理程序实现服务器端文件处理,其实这些都不是我主要想说的。我想说的是网上很对uploadify初始化的代码很有问题,比如:下面代码
$(
"#uploadify"
).uploadify({
'uploader': 'JS/jquery.uploadify-v2.1.0/uploadify.swf',
'script': 'UploadHandler.ashx',
'cancelImg': 'JS/jquery.uploadify-v2.1.0/cancel.png',
'folder':'UploadFile',
'queueID':'fileQueue',
'auto':false,
'multi':true
}); });
在这段代码中有的Option在3.2.1的版本中根本就没有...所以怎么用也得不到想要的结果... 在3.2.1的版本中一般处理程序应该写在‘uploader’选项中,在文件上传之后就会进入一般处理程序对文件进行处理,
也就是‘uploader’:'UploadHandler.ashx'
在3.2.1版本中有一下option,后面是它的默认值
// Required Settings
id : $this.attr('id'), // The ID of the DOM object
swf : 'uploadify.swf', // The path to the uploadify SWF file
uploader : 'uploadify.php', // The path to the server-side upload script
// Options
auto : true, // Automatically upload files when added to the queue
buttonClass : '', // A class name to add to the browse button DOM object
buttonCursor : 'hand', // The cursor to use with the browse button
buttonImage : null, // (String or null) The path to an image to use for the Flash browse button if not using CSS to style the button
buttonText : 'SELECT FILES', // The text to use for the browse button
checkExisting : false, // The path to a server-side script that checks for existing files on the server
debug : false, // Turn on swfUpload debugging mode
fileObjName : 'Filedata', // The name of the file object to use in your server-side script
fileSizeLimit : 0, // The maximum size of an uploadable file in KB (Accepts units B KB MB GB if string, 0 for no limit)
fileTypeDesc : 'All Files', // The description for file types in the browse dialog
fileTypeExts : '*.*', // Allowed extensions in the browse dialog (server-side validation should also be used)
height : 30, // The height of the browse button
itemTemplate : false, // The template for the file item in the queue
method : 'post', // The method to use when sending files to the server-side upload script
multi : true, // Allow multiple file selection in the browse dialog
formData : {}, // An object with additional data to send to the server-side upload script with every file upload
preventCaching : true, // Adds a random value to the Flash URL to prevent caching of it (conflicts with existing parameters)
progressData : 'percentage', // ('percentage' or 'speed') Data to show in the queue item during a file upload
queueID : false, // The ID of the DOM object to use as a file queue (without the #)
queueSizeLimit : 999, // The maximum number of files that can be in the queue at one time
removeCompleted : true, // Remove queue items from the queue when they are done uploading
removeTimeout : 3, // The delay in seconds before removing a queue item if removeCompleted is set to true
requeueErrors : false, // Keep errored files in the queue and keep trying to upload them
successTimeout : 30, // The number of seconds to wait for Flash to detect the server's response after the file has finished uploading
uploadLimit : 0, // The maximum number of files you can upload
width : 120, // The width of the browse button