简体   繁体   English

简单的PHP多文件上传不会将文件发送到服务器

[英]simple PHP multiple file upload does not send files to server

I have this code 我有这个代码

<form method="post" id="usrForm" enctype="multipart/form-data">
     <input type="file" multiple accept=".jpg,.jpeg,.gif" name="fl[]"/>
</form>

//Some Other tags and elements
<input type="button" id="formSubmit" onclick="$('#usrForm').submit()"/>

In php, when I echo print_r($_FILES["fl"]) I get empty array like this 在php中,当我回显print_r($ _ FILES [“ fl”])时,我得到这样的空数组

Array ( [name] => Array ( [0] => ) [type] => Array ( [0] => ) [tmp_name] => Array ( [0] => ) [error] => Array ( [0] => 4 ) [size] => Array ( [0] => 0 ) ) 

and therefore I cannot upload any images etc. What am I doing wrong? 因此我无法上传任何图像等。我在做什么错? I have been wondering for about 3 hours searching different articles but all in vein. 我一直想知道大约3个小时都在搜索不同的文章,但都是如此。

you should define enctype use 您应该定义enctype的用法

<form method="post" id="usrForm" enctype="multipart/form-data">

insted of 装的

<form method="post" id="usrForm">

update 更新

your code works fine 您的代码工作正常

make sure file upload is On, on php.ini 确保文件上传在php.ini上处于启用状态

file_uploads = On; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM