php AJAX 表单提交并上传文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5561127/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 21:48:57  来源:igfitidea点击:

AJAX form submit with file upload

phpajaxforms

提问by

Hey guys. I am trying to ajax submit a form that contains file upload area. As i found out JS cannot handle file uploads therefore I am using this plugin -> http://jquery.malsup.com/form/#ajaxForm

大家好。我正在尝试 ajax 提交一个包含文件上传区域的表单。由于我发现 JS 无法处理文件上传,因此我正在使用此插件 -> http://jquery.malsup.com/form/#ajaxForm

However, after submitting the form, I am not getting anything in $_FILES. Does anyone know what is the reason and how I can fix this?

但是,提交表单后,我没有收到任何内容$_FILES。有谁知道是什么原因以及如何解决这个问题?

My input field is <input type="file" name="logo" id="logo" />and yes the form is multipart data.

我的输入字段是<input type="file" name="logo" id="logo" />,是的,表单是多部分数据。

Thanks.

谢谢。

回答by zamoldar

use this plugin it uses XHR for uploading multiple files with progress-bar in FF3.6+, Safari4+, Chrome and falls back to hidden iframe based upload in other browsers, providing good user experience everywhere. check this: http://valums.com/ajax-upload/

使用这个插件,它使用 XHR 在 FF3.6+、Safari4+、Chrome 中上传带有进度条的多个文件,并在其他浏览器中回退到基于隐藏 iframe 的上传,在任何地方都提供良好的用户体验。检查这个:http: //valums.com/ajax-upload/