JQuery上传插件Uploadify31中文超级详细参考.docx
《JQuery上传插件Uploadify31中文超级详细参考.docx》由会员分享,可在线阅读,更多相关《JQuery上传插件Uploadify31中文超级详细参考.docx(15页珍藏版)》请在冰豆网上搜索。
JQuery上传插件Uploadify31中文超级详细参考
JQuery上传插件Uploadify超级详细中文使用手册
Uploadify配置选项:
●auto类型:
Boolen缺省值:
true
说明:
表示在选择文件后是否自动上传
●buttonClass
说明:
额外增加的上传按钮样式类型
●buttonCursor
说明:
上传按钮Hover时的鼠标形状,默认值是’hand’
●buttonImage
说明:
按钮的背景图片,默认为NULL
●buttonText
说明:
按钮上显示的文字,默认”SELECTFILES”
●checkExisting
说明:
默认是false,若要检查可指明一个用于判断的脚本的路径,比如:
‘checkExisting’:
’/uploadify/check-exists.php’
●debug
说明:
开启DEBUG模式,默认False
●fileObjName
说明:
文件对象名称。
用于在服务器端获取文件。
比如,把该属性设置为’myFile’,那么在PHP中获取该文件的方法是:
$_FILES[‘myFile’],该属性的缺省值为:
‘Filedata’
●fileSizeLimit
说明:
上传文件大小限制,默认单位是KB,若需要限制大小在100KB以内,可设置该属性为:
’100KB’
●fileTypeDesc
说明:
文件类型的说明,比如设置该属性为:
’AnyOldfileyouwant…’,那么,选择文件时可以看到(图片右下角):
●fileTypeExts
指定允许上传的文件类型。
默认*.*。
比如只支持gif,jpg,png类型的图像,那么该属性设置为:
‘*.gif;*.jpg;*.png’
●formData
指定上传文件附带的其他数据。
也可以动态设置。
下面看一个静态的例子:
其中,formData中包含两个键值对,在服务器端可以通过$_POST或者$_GET
获取这些数据。
若要动态设置参数的值,可以通过onUploadStart方法,传入参数”settings”如上图示,其把名为someOtherKey的变量的值改成了2.
●height
表示按钮的高度,默认30PX。
若要改为50PX,如下设置:
‘height‘:
50,
●method
默认是’post’,也可以设置为’get’
●multi
是否支持多文件上传,默认为true
●overrideEvents
Uploadify插件里面有一些事件,该参数意义就是设置哪些事件可以被用户覆写。
若进行如下设置:
表示onUploadProgress事件可以被用户自定义的事件覆盖。
●preventCaching
若设置为true,一个随机数将被加载swf文件URL的后面,防止浏览器缓存。
默认值为true
●progressData
设置文件上传时显示的数据,有两个选择:
‘上传速度‘或者’百分比‘,分别对应’speed’和’percentage’
●queueID
表示上传队列的DOM元素的ID号,如下所示:
设置了queueID为some_file_queue,那么选择多个文件上传后,就能看到实时的队列情况,如下图所示:
●queueSizeLimit
队列长度限制,缺省值999
●removeCompleted表示在上传完成后是否删除队列中的对应元素。
默认是True,即上传完成后就看不到上传文件进度条了。
●removeTimeout
表示上传完成后多久删除队列中的进度条,默认为3,即3秒。
●requeueErrors
若设置为True,那么在上传过程中因为出错导致上传失败的文件将被重新加入队列。
●successTimeout
表示文件上传完成后等待服务器响应的时间。
超过该时间,那么将认为上传成功。
默认是30,表示30秒。
●swf
swf文件路径
●uploader
服务器端脚本文件路径
●uploadLimit
最多上传文件数量,默认999
●width
按钮宽度,默认120
1.Uploadify事件:
●onCancel
在文件被移除出队列时触发
●onClearQueue
在调用cancel方法且传入参数’*’时触发
●onDestroy
调用destroy方法时触发
●onDialogClose
打开文件对话框关闭时触发
参数queueData有以下属性:
∙filesSelected
Thenumberoffilesselectedinbrowsefilesdialog
∙filesQueued
Thenumberoffilesaddedtothequeue(thatdidn’treturnanerror)
∙filesReplaced
Thenumberoffilesreplacedinthequeue
∙filesCancelled
Thenumberoffilesthatwerecancelledfrombeingaddedtothequeue(notreplaced)
∙filesErrored
Thenumberoffilesthatreturnedanerror
●onDialogOpen
选择文件对话框打开时触发。
●onDisable
禁用Uploadify时触发(通过disable方法)
●onEnable
使能Uploadift时触发
●onFallback
没有兼容的FLASH时触发
●onInit
每次初始化一个队列时触发
●onQueueComplete
在队列中的文件上传完成后触发
●onSelect
选择文件后触发
●onSelectError
选择文件后出错时触发。
参数如下
∙file
Thefileobjectthatreturnedtheerror.
∙errorCode
Theerrorcodethatwasreturned.Thefollowingconstantscanbeusedwhendeterminingtheerrorcode:
∙QUEUE_LIMIT_EXCEEDED–Thenumberoffilesselectedwillpushthesizeofthequeuepassedthelimitthatwasset.
∙FILE_EXCEEDS_SIZE_LIMIT–Thesizeofthefileexceedsthelimitthatwasset.
∙ZERO_BYTE_FILE–Thefilehasnosize.
∙INVALID_FILETYPE–Thefiletypedoesnotmatchthefiletypelimitationsthatwereset.
∙errorMsg
Theerrormessageindicatingthevalueofthelimitthatwasexceeded.
*Youcanaccessafullerrormessageusing‘this.queueData.errorMsg’ifyoudonotoverridethedefaulteventhandler.
●onSWFReady
FLASH对象加载成功后触发
●onUploadComplete
上传文件成功后触发(每一个文件都触发一次)
●onUploadError
上传文件失败触发,参数如下:
∙file
Thefileobjectthatwasuploaded
∙errorCode
Theerrorcodethatwasreturned
∙errorMsg
Theerrormessagethatwasreturned
∙errorString
Thehuman-readableerrormessagecontainingallthedetailsoftheerror
●onUploadProgress
每个文件上传后更新一次进度信息。
参数如下:
∙file
Thefileobjectbeinguploaded
∙bytesUploaded
Thenumberofbytesofthefilethathavebeenuploaded
∙bytesTotal
Thetotalnumberofbytesofthefile
∙totalBytesUploaded
Thetotalnumberofbytesuploadedinthecurrentuploadoperation(allfiles)
∙totalBytesTotal
Thetotalnumberofbytestobeuploaded(allfiles)
●onUploadStart
在一个文件开始上传之前触发。
●onUploadSuccess
在每一个文件上传成功后触发参数如下:
∙file
Thefileobjectthatwassuccessfullyuploaded
∙data
Thedatathatwasreturnedbytheserver-sidescript(anythingthatwasechoedbythefile)
∙response
Theresponsereturnedbytheserver—trueonsuccessorfalseifnoresponse.Iffalseisreturned,afterthesuccessTimeoutoptionexpires,aresponseoftrueisassumed.
2.Uploadify方法:
●cancel
●destroy
●disable
●settings
参数
●name
Thenameofthesettingyouwanttoreturnorchange.Onlysettingthisargumentwillreturnthevalue.
●value
Thevalueyouwouldliketouseforthesetting.
●resetObjects
SetthistotruewhenupdatingthepostDataobjecttoeraseexistingvalues.Otherwise,newvalueswillbeaddedtoexistingones.
*Theonlysettingthatcannotbesetistheswfsetting.
●stop停止上传
●upload
参数:
fileID
TheIDofthefileyouwouldliketoupload.TheeasiestwaytogetthefileIDofaqueueitemistousetheidattributeofthequeueitemyouwanttoupload.Touploadmultiplefiles,addeachfileIDasanargument.If‘*’ispassedasthefirstandonlyargument,allfilesinthequeuewillbeuploaded.