Jquery Uploadify使用參數詳解


本文引自SatSunStudio

 

以下是可選項的參數說明:(紅色的屬性代表常用的)

1 uploader uploadify.swf文件的相對路徑,該swf文件是一個帶有文字BROWSE的按鈕,點擊后淡出打開文件對話框,flash控件 

 

默認值=’uploadify.swf’

2 script 

 

相對路徑的后端腳本,它將處理您上傳的文件。 

 

絕對路徑前綴或’/'或’http’的路徑

默認值=’uploadify.php’

3 checkScript 

 

檢查該文件是否已經選擇駐留在服務器上(用來判斷上傳選擇的文件在服務器是否存在的后台處理程序的相對路徑)。
沒有默認值。 官方例子中’check.php’是提供核心文件
4 scriptData 

 

可提供URL傳遞參數。用來傳遞get參數。例如: 

 

index.jsp?id=1&action=uploadify可以設置成:

‘script’: ‘index.jsp’,

‘scriptData’:{‘id’:1,’action’:'uploadify’},

注:要設置‘method’:‘GET’.

5 fileDataName 

 

您的文件在上傳服務器腳本陣列的名稱。
默認值=’Filedata’
6 method 

 

設置為發送到后端腳本的方法。要么’get’或post’。 

 

默認值’post’

7 scriptAccess 

 

flash腳本文件的訪問模式,如果在本地測試設置為always,默認值:sameDomain
8 folder 

 

您想將文件保存到的路徑。考慮到安全問題,一般並不在客戶端設定后供服務器得到所存的路徑。我試了下。這個參數好像以get的方式傳遞的。設定post得不到這個值。
9 queueID 

 

文件隊列ID。該ID與存放文件隊列的div的ID一致。參考上一篇例子的用法。
10 queueSizeLimit 

 

限制在一次隊列中的次數(可選定幾個文件)。默認值= 999,而一次可傳幾個文件有 simUploadLimit屬性決定
11 multi 

 

是否允許同時上傳多文件,可設定true或false。 

 

默認false。設定true時,選中的文件是當前項。

12 auto 

 

 

選定文件后是否自動上傳,可設定true或false。 

 

默認false

13 fileDesc 

 

出現在上傳對話框中的文件類型描述。與fileExt需同時使用
14 fileExt 

 

支持的格式,啟用本項時需同時聲明fileDesc。 

 

如:‘*.rar;*.doc

15 sizeLimit 

 

控制上傳文件的大小,單位byte
16 simUploadLimit 

 

多文件上傳時,同時上傳文件數目限制。默認1 

 

一次可傳幾個文件。

17 buttonText 

 

默認按鈕的名字。默認BROWER
18 buttonImg 

 

使用圖片按鈕,設定圖片的路徑即可。
19 hideButton 

 

上傳按鈕的隱藏。true 或false。默認flase
20 rollover 

 

值為true和false,設置為true時當鼠標移到瀏覽按鈕上時有反轉效果。
21 width 

 

 

按鈕圖片的長度。默認 110
22 height 

 

按鈕圖片的高度。默認 30
23 wmode 

 

背景透明transparent 與不透明opaque設定。默認 不透明 

 

24 cancelImg 

 

取消按鈕。設定圖片路徑。默認cancel.png 

 

 

25 onInit 

 

函數, 初始化時的狀態。 

 

onInit: function() {

$(“#id”).html(“上傳前”);},

26 onComplete 

 

函數:可傳遞五個參數 

 

event: 事件對象

queueID: 完成文件的唯一標識符。

fileObj:

• name – 文件名

• filepath –上傳路徑

• size – 文件大小

• creationDate – 文件創建時間

• modificationDate文件最近修改時間

• type –文件的擴展名

response: 服務器回調的數據

data:

• fileCount – The total number of files left in the queue

• speed – 平均上傳速度 KB/s

如:

onComplete: function(event, queueID, fileObj) {

alert(“文件:” +fileObj.name + “上傳失敗”);  }

 

27 onSelectOnce 

 

函數:可傳遞二個參數 

 

event: The event object.

data: An object containing details about the select operation.

• fileCount – The total number of files in the queue

• filesSelected – The number of files selected in the select operation

• filesReplaced – The number of files that were replaced in the queue

• allBytesTotal – The total number of bytes for all files in the queue

 

28 onCancel 

 

函數:可傳遞四個參數 

 

event: The event object.

queueID: The unique identifier of the file that was cancelled.

fileObj: An object containing details about the file that was selected.

• name – The name of the file

• size – The size in bytes of the file

• creationDate – The date the file was created

• modificationDate – The last date the file was modified

• type – The file extension beginning with a ‘.’

data: Details about the file queue.

• fileCount – The total number of files left in the queue

• allBytesTotal – The total number of bytes left for all files in the queue

 

29 onClearQueue 

 

函數:可傳遞一個參數 

 

event: The event object.

30 onQueueFull 

 

函數:可傳遞二個參數 

 

• event – The event object.

• queueSizeLimit – The maximum size of the queue.

31 onError 

 

函數:可傳遞四個參數 

 

event: The event object.

queueID: The unique identifier of the file that was errored.

fileObj: An object containing details about the file that was selected.

• name – The name of the file

• size – The size in bytes of the file

• creationDate – The date the file was created

• modificationDate – The last date the file was modified

• type – The file extension beginning with a ‘.’

errorObj: An object containing details about the error returned.

• type – Either ‘HTTP’, ‘IO’, or ‘Security’

• info – An error message describing the type of error returned

32 onOpen 

 

函數:可傳遞三個參數 

 

event: The event object.

queueID: The unique identifier of the file that was opened.

fileObj: An object containing details about the file that was selected.

• name – The name of the file

• size – The size in bytes of the file

• creationDate – The date the file was created

• modificationDate – The last date the file was modified

• type – The file extension beginning with a ‘.’

33 onProgress 

 

函數:可傳遞四個參數 

 

event: The event object.

queueID: The unique identifier of the file that was updated.

fileObj: An object containing details about the file that was selected.

• name – The name of the file

• size – The size in bytes of the file

• creationDate – The date the file was created

• modificationDate – The last date the file was modified

• type – The file extension beginning with a ‘.’

data: An object containing details about the upload and queue.

• percentage – The current percentage completed for the upload

• bytesLoaded – The current amount of bytes uploaded

• allBytesLoaded – The current amount of bytes loaded for all files in the queue

• speed – The current upload speed in KB/s

34 onSelect 

 

event: The event object. 

 

queueID: The unique identifier of the file that was selected.

fileObj: An object containing details about the file that was selected.

• name – The name of the file

• size – The size in bytes of the file

• creationDate – The date the file was created

• modificationDate – The last date the file was modified

• type – The file extension beginning with a ‘.’

 

35 onAllComplete 

 

函數:可傳遞二個參數 

 

event: The event object.

data: An object containing details about the upload process.

• filesUploaded – The total number of files uploaded

• errors – The total number of errors while uploading

• allbytesLoaded – The total number of bytes uploaded

• speed – The average speed of all uploaded files

 

36 onCheck 

 

函數:可傳遞五個參數 

 

event: The event object.

checkScript: The path to the file checking script.

fileQueue: A file queue object consisting of  key/value pairs with the queue ID as the key and the filename as the value.

folder: The path to the upload folder.

single: True if only one file is being uploaded from the queue.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM