0

What I'm trying to do upload multiple images from a single click using POST method. Path of each image saving in Database as I want to but nothing getting stored on that local folder path. I am taking multiple images from multiple inputs, not from the single input.

Input File to upload single then click on ADD to add another from another file_input tag.. and so on.

Array ( [0] => Array ( [attachment] => 8.jpg ) [1] => Array ( [attachment] => 3-D80A.JPG ) )

Front

   <form method="post" action="">
    <input type="file" id="file" name="attachment[0][attachment]">
    <input type="file" id="file" name="attachment[1][attachment]">
    <input type="submit" name="submit_case" value="Save" class="btn btn-primary">
    </form>

Back

foreach (array_keys($_FILES["attachment"]["name"]) as $fieldKeysymtoms) {
     foreach ($_FILES["attachment"]["name"][$fieldKeysymtoms] as $key=>$value) {
       print_r($_FILES["attachment"]["name"][$fieldKeysymtoms]);
       if(move_uploaded_file($_FILES["attachment"]["tmp_name"][$fieldKeysymtoms], "app-assets/images/".$name)){
         $uploads = "app-assets/images/".$name;              
       }
       $json_symtoms_array+=array($fieldKeysymtoms => $value);
     }
   }
  • 1
    Possible duplicate of [Multiple Image Upload PHP form with one input](https://stackoverflow.com/questions/24895170/multiple-image-upload-php-form-with-one-input) – John M Nov 21 '18 at 08:14
  • Can you show the actual code you use? – Jarek.D Nov 21 '18 at 09:37
  • @Jarek.D here's the code – Anish Kumar Nov 21 '18 at 10:03
  • can you double check if your web server user has a write permission on 'app-assets/images folder? You might do it by trying to write a test file using file_put_contents into that folder from within your php script – Jarek.D Nov 21 '18 at 10:47
  • Yes they have permissions to write into the folder, we create the folder with 777 permission each time when no folder there – Anish Kumar Nov 21 '18 at 10:56

0 Answers0