0
內容我有以下文件上傳多個文件輸入想要替換第一個與第二
<input type="file" name="files2[]" multiple onchange="readURL(this);" size="1" class="input-file" />
我需要以某種方式替換文件[]與files2 []當files2是組。
這裏是(文件/文件)中的內容:
Array ([files] => Array ([name] => Array ([0] =>c GIF.gif) [type] => Array ([0] => image/gif) [tmp_name] => Array ([0] => C:\Windows\Temp\phpF943.tmp) [error] => Array ([0] => 0) [size] => Array ([0] => 9921)) [files2] => Array ([name] => Array ([0] => 14 beresford.png [1] => combination-boilerc2.jpg) [type] => Array ([0] => image/png [1] => image/jpeg) [tmp_name] => Array ([0] => C:\Windows\Temp\phpF944.tmp [1] => C:\Windows\Temp\phpF955.tmp) [error] => Array ([0] => 0 [1] => 0
我曾嘗試下面的條件,但是這似乎並沒有得到滿足
if (!empty($_FILES['files2']['error'][0])) {
$_FILES['files']=$_FILES['files2'];
}
如果我改變了對下面的條件總是滿足,導致文件[]的內容也是空的。
if (!empty($_FILES['files2'])) { //this is always reached even if files 2 is empty...
$_FILES['files']=$_FILES['files2'];
}
Array ([files] => Array ([name] => Array ([0] =>) [type] => Array ([0] =>) [tmp_name] => Array ([0] =>) [error] => Array ([0] => 4) [size] => Array ([0] => 0)) [files2] => Array ([name] => Array ([0] =>) [type] => Array ([0] =>) [tmp_name] => Array ([0] =>) [error] => Array ([0] => 4) [size] => Array ([0] => 0))) 0 is an Invalid file type:
*註文件和files2是混亂的名字輸入,清楚地意識到這一點;)