-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数组中)?