我的页面中有一个上传器,设计为在 iPad 上工作,并且有 8 个上传框。
当我在上传器中上传图片时,只保存一个文件。
我怎样才能让它保存所有上传的图片?
- 文件夹设置为 777。
PHP:
<?
if ( isset( $_POST['submit'] ) ){
foreach ($_FILES['file']['name'] as $_key => $_value){
if($_FILES['file']['size'][$_key] !==0){
$randomizer = rand(0000000, 9999999);
$f=$randomizer.$_FILES['file']['name'][$_key];
echo $f;
echo "<br>";
$t=$_FILES['file']['tmp_name'][$_key];
echo $t;
echo "<br>";
//echo $_FILES['file']['size'][$_key]."<br />";
$file_mb = round(($_FILES["file"]["size"][$_key] / 1048576), 2);
echo "Size: " . $file_mb . " Mb<br />";
echo $_FILES['file']['type'][$_key]."<br />";
if( file_exists($t) ){ move_uploaded_file($t, 'upload/' . $f); }
//move_uploaded_file($_FILES['file']['tmp_name'][$_key], "upload"/$_FILES['file']['name'][$_key]);
echo "ok file";
echo "<br>";
}
}
}
?>
<form id="main_form" action="" method="POST" enctype="multipart/form-data">
<? for($i = 0; $i < 9; $i++) {
echo "<input type=\"file\" name=\"file[]\" /> <br>";
}
?>
<input type="submit" name="submit" value="send">
</form>
HTML:
<input type="file" name="image1" /><br /> <br /> <br />
<input type="file" name="image2" /><br /> <br /> <br />
<input type="file" name="image3" /><br /> <br /> <br />
<input type="file" name="image4" /><br /> <br /> <br />
<input type="file" name="image5" /><br /> <br /> <br />
<input type="file" name="image6" /><br /> <br /> <br />
<input type="file" name="image7" /><br /> <br /> <br />
<input type="file" name="image8" /><br /> <br /> <br />