我正在嘗試在我的項目中使用blueimp jQuery File Upload。它非常適合我的需求,但我需要更改創建和配置插件後動態上傳的url文件。我做了很多調查,但不幸的是,沒有發現任何用處。一般來說,我有一個按鈕來選擇文件和文件上傳操作,覆蓋實際上傳。基本的創作是這樣的:jQuery文件上傳:如何動態更改上傳網址
$('[upload-button]').fileupload(new FileUploadConfig())
而且配置本身:
function FileUploadConfig() {
// is set to a unique value for each file upload
this.url = 'temporary';
this.fileInput = $('[upload-button]');
//... some other code
}
我需要做的就是改變這種配置的URL,然後調用data.submit()
。我發現,這個配置是使用$.data()
保存,並試圖用這樣的代碼
// get the current fileupload configuration
var config = $.data($('[upload-button]').get(0), 'fileupload');
// change the url configuration option
config.options.url = file.link;
//send a file
data.submit();
來解決這個問題。然而,這並不工作,我想要的方式。
有關如何完成此任何想法?
你能解釋這一點?就像你把這個腳本放在哪裏等等。我已經成功地能夠使用PHP,但是下載/刪除停止工作上傳到不同的目錄。我不想發佈/獲取新的目錄變量,我寧願使用jquery/javascript。 – VIDesignz
不能正常工作,甚至在更換之後b更改 var that = $(this).data('fileupload'); by var that = $(this).data('blueimp-fileupload'); –