Javascript 通过ajaxform上传文件不起作用
我试图通过AJAX调用(&PHP)上传一个图像。我使用ajaxform插件来实现这一点,但显然,当我提交表单时,“文件”输入值并没有传递给php脚本。这是我的HTML&JS:Javascript 通过ajaxform上传文件不起作用,javascript,php,ajaxform,Javascript,Php,Ajaxform,我试图通过AJAX调用(&PHP)上传一个图像。我使用ajaxform插件来实现这一点,但显然,当我提交表单时,“文件”输入值并没有传递给php脚本。这是我的HTML&JS: <form action="upload_file.php" method="post" enctype="multipart/form-data" id="select-image"> <input type="file" name="image" size="30"/> <inpu
<form action="upload_file.php" method="post" enctype="multipart/form-data" id="select-image">
<input type="file" name="image" size="30"/> <input type="submit" name="upload" value="Upload" />
</form>
<script>
var options = {
success: showResponse // post-submit callback
};
// bind form using 'ajaxForm'
$('#select-image').ajaxForm(options);
// post-submit callback
function showResponse(responseText, statusText, xhr, $form) {
alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
'\n\nThe output div should have already been updated with the responseText.');
}
</script>
我做错什么了吗?我甚至可以通过Ajaxform插件上传图像吗?请给我一些建议
谢谢。尝试在var选项中添加“cache:false”
var options = {
cache : false,
success: showResponse // post-submit callback
};
对我有用
Array(
[image]=>
)
var options = {
cache : false,
success: showResponse // post-submit callback
};