我提交的表单包含一些文本字段,下拉列表和文件输入。表单使用JQuery / Ajax提交,数据发送到php。如果我在不使用bootstrapFileInput的情况下提交表单,表单的所有数据都将被发送到php并正确处理,但是一旦启用bootstrapFileInput,输入文件就会丢失,而所有其他字段都被正确提交。 我在控制台中没有出错。
HTML:
<div class="form-inline">
<div id="singUser">
<form role="form" name="setLimit" id="setLimit" class="form-inline" enctype="multipart/form-data">
<input type="text" id="userid" name="userid" class="form-control" placeholder="Enter User ID">
<input type="text" id="quota" name="quota" class="form-control" placeholder="Enter Quota limit in GB">
<select class="form-control" id="ltype" name="ltype">
<option value="desktop">Desktop</option>
<option value="server">Server</option>
</select>
<input type="checkbox" id="rmlimit" name="rmlimit"> Remove Limit (Set to Shared storage)
<button type="submit" id="sgUserButn" class="btn btn-default btn-primary" >Set Limit!</button>
</div>
<span id="multUser">
<p>Select a file with a list of user ids and the limit in GB you wish to assign <a href="template/template.csv">download the example file.</a></p>
<img src="img/csvex.png" id="csvexp" ><br><br>
<input class="file-input-wrapper" type="file" id="lsUsers" name="lsUsers" data-filename-placement="inside" title="Select CSV File">
<button id="mulUserButn" type="submit" class="btn btn-default btn-primary" >Set Limit!</button>
</span>
</form>
</div>
JQuery
$(document).ready(function() {
$.ajaxSetup({
cache: false
});
$('input[type=file]').bootstrapFileInput();
$('.file-inputs').bootstrapFileInput();
$('#setLimit')
.submit(function(e) {
busyStatus();
$.ajax({
url: 'testProcess.php',
type: 'POST',
data: new FormData(this),
processData: false,
contentType: false,
complete: function() {
idleStatus();
},
success: function(result) {
//$(document.body).append(result);
//alert( $(result).toArray() );
$("#result").html(result);
}
});
e.preventDefault();
return false;
});
});
PHP
<?php
print_r($_POST);
echo '<br>';
print_r($_FILES);
?>
我真的没有想法,真的很感激一些帮助。 提前谢谢。