-1
我有一個JQuery文件上傳的表單。形式是:jQuery文件上傳 - 在表單上提交文件
<form action="" method="post" name="job_offer_reply" id="job_offer_reply" enctype="multipart/form-data">
<textarea name="description" id="description" class="form-control" rows="3"></textarea>
<div id="drop">
<?php _e('Drop You CV Here', 'ja'); ?>
<a><?php _e('OR Browse', 'ja'); ?></a>
<input type="file" name="upl" multiple/>
</div>
<input id="submit" type="submit" class="btn btn-primary" name="submit" value="Submit">
</form>
文件上傳初始化函數(縮短)爲:
$(function(){
$('#drop a').click(function(){
// Simulate a click on the file input button
// to show the file browser dialog
$(this).parent().find('input').click();
});
// Initialize the jQuery File Upload plugin
$('#job_offer_reply').fileupload({
formData: {
action: 'ja_upload_cv',
},
dropZone: $('#drop'),
add: function (e, data) {
// Automatically upload the file once it is added to the queue
var jqXHR = data.submit();
},
done:function(e, data){
console.log(data);
},
fail:function(e, data){
// Something has gone wrong!
data.context.addClass('error');
}
});
});
該代碼上傳的文件,只要它被選中/下降。當我刪除
var jqXHR = data.submit();
即使在表單提交後,它也不會被提交。
當點擊提交按鈕時,如何上傳文件(將它放在我的$ _FILES數組中)?