简体   繁体   English

多个文件上传脚本在php中不起作用

[英]multiple file upload script not working in php

im using java script to upload multiple images but some how its no working ...only the first file gets uploaded. 即时通讯使用Java脚本上传多个图像,但是有些不起作用...仅第一个文件被上传。 javascript works standalone but when i integrate it with my existing code it doesnt. javascript是独立运行的,但是当我将其与现有代码集成时,它不会。 im refering the same php file after submit and then using if($_REQUEST['Submit']). 即时通讯提交后,然后使用if($ _ REQUEST ['Submit'])引用相同的php文件。 i have tried fixing the number of elements it works....but cant get it working dynamically 我试图修复它可以工作的元素数量....但是无法使其动态工作

Name the inputs with square brackets at the end of their name. 用名称末尾的方括号命名输入。 If there is no value inside the brackets, they will be put sequentially into an array. 如果方括号内没有值,则将它们顺序放入数组中。 If there is a value, that will be used as the key in the array: 如果有一个值,它将用作数组中的键:

HTML: HTML:

<input type="hidden" name="inp[]" value="a" />
<input type="hidden" name="inp[]" value="b" />
<input type="hidden" name="inp[]" value="c" />
<input type="hidden" name="inp[foo]" value="bar" />

PHP: PHP:

print_r($_POST);
/* 
array(
    0 => 'a',
    1 => 'b',
    2 => 'c',
    'foo' => 'bar'
)
*/

The same should apply to the $_FILES array. $_FILES数组也应如此。

PHP has a max_upload_size and max_post_size If your upload post size exceeds these then uploads often fail. PHP具有max_upload_size和max_post_size如果您的上传帖子大小超出了这些限制,则上传通常会失败。 Make sure you have these set real high, I usually set 200M+ 确保您已将这些设置设为很高,我通常设置为200M +

use phpinfo() to get what these values are set too 使用phpinfo()也可以设置这些值

A better option is to have your script upload each file one at a time in the background 更好的选择是让脚本一次在后台上传每个文件

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

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