0

私のページには、iPad から動作するように設計されたアップローダーがあり、8 つのアップロード ボックスがあります。

アップローダーで画像をアップロードすると、ファイルが 1 つだけ保存されます。

アップロードされたすべての写真を保存するにはどうすればよいですか?

  • フォルダは 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 />
4

0 に答える 0