post方法提交表单 如何获取文件

WBOY
Release: 2016-06-20 12:31:17
Original
1375 people have browsed it

<form method="post" action="execute.html?m=&a=designer&f=designerList">        <input type='file' name="test">        <button type="submit">提交</button>    </form>  
Copy after login

public function designerList()       {		echo "<pre class="brush:php;toolbar:false">";		print_r($_POST);		print_r($_FILES);	}
Copy after login


最后输出来的$_post是一个文件名,$_files是一个空数组。
我该怎么去获取这个文件呢?


回复讨论(解决方案)



非常感谢~再问一个额外的问题~如果我想要用ajax方法提交的话,文件我改怎么处理?貌似调用serialize()的方法不行 ~

提交到隐藏的iframe来模拟,如果不考虑兼容ie9-,可以用h5的formdata对象,用formdata对象可以添加文件对象。

或者用jquery.form.js这个jquery插件,支持formdata就用formdata+ajax,否则iframe模拟。。

提交到隐藏的iframe来模拟,如果不考虑兼容ie9-,可以用h5的formdata对象,用formdata对象可以添加文件对象。

或者用jquery.form.js这个jquery插件,支持formdata就用formdata+ajax,否则iframe模拟。。



非常感谢~我去试试~
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!