我使用jQuery uploadify插件上傳文件。 Each time I upload a file, a hidden field is created in the form with uploaded file path on server.當我提交表單時,我將該文件路徑從隱藏字段中存儲到數據庫中。它爲我工作。一個問題是我在uploadify的onComplete
函數中硬編碼表單對象。如何獲得表單對象whos元素被點擊
這裏是我的代碼:
的jQuery:
$('.FileUpload').uploadify({
'uploader' : '/uploadify/uploadify.swf',
'script' : '/uploadify/uploadify.php',
'cancelImg' : '/uploadify/cancel.png',
'folder' : '/uploads',
'auto' : true,
'queueID' : 'fileQueue',
'removeCompleted':false,
'onComplete' : function(event, ID, fileObj, response, data) {
// It is hard coded here. It may create probelems
// if there are multiple file upload buttons.
// How can I do this with '$(this)' keyword or something
$('.SingleFileUpload').parents('form').append('<input type="hidden" name="uploaded_file" value="' + response + '">');
}
});
我怎樣才能只形成誰的文件瀏覽按鈕被點擊onComplete()
功能。我認爲你明白了我的觀點?
感謝
感謝。它給了我一個方向。我也發佈了我的完整解決方案。謝謝。 – Student