我正在使用FormData
发送multipart/form-data
并在PHP中获取它,它可以在Chrome中正常运行,但在Firefox中无效。
这是我的JS
$.ajax({
type: "POST",
url: postUrl,
dataType: "json",
data: new FormData($("#form")[0]),
processData: false,
contentType: false,
success: function (response) {
}
});
我的HTML代码,
<form action="" method="post" enctype="multipart/form-data" id="form">
<input type="text" class="form-control" value="" id="name" name="name">
<input type="file" id="resourceFile" name="resourceFile">
</form>
这是我的Php代码
echo $_POST["name"] // name field is in form
In chrome I am getting value for name but in Firefox it's saying
Undefined index: name.
This i am getting on print_r($_POST) for Firefox
Array ( [-----------------------------183019406712953243052078205169 Content-Disposition:_form-data;_name] => "name" sdgdxgf -----------------------------183019406712953243052078205169-- )
This i am getting on print_r($_POST) for Chrome
Array ( [name] => sdgdxgf )