0

I'm having issues with an image uploading form in Laravel. On my localhost everything is working fine, but when i push to a server the images don't get passed to the controller. The form has the enctype="multipart/form-data" This is my form-field for the upload

<div class="form-group">
    <div class="col">
        <label for="photos">Add images here</label>
        <input multiple="multiple" type="file" name="photos[]" class="form-control">
    </div>
</div>

When is submit the form and put dd($request);at the beginning of my controller, I get these responses:

Local:

+files: Symfony\Component\HttpFoundation\FileBag {#57 ▼
    #parameters: array:1 [▼
      "photos" => array:1 [▼
        0 => Symfony\Component\HttpFoundation\File\UploadedFile {#42 ▼
          -test: false
          -originalName: "photo.jpg"
          -mimeType: "image/jpeg"
          -error: 0
          path: "/private/var/tmp"
          filename: "phpdwAuus"
          basename: "phpdwAuus"
          pathname: "/private/var/tmp/phpdwAuus"
          extension: ""
          realPath: "/private/var/tmp/phpdwAuus"
          aTime: 2020-01-06 13:43:53
          mTime: 2020-01-06 13:43:53
          cTime: 2020-01-06 13:43:53
          inode: 8623609813
          size: 3142496
          perms: 0100600
          owner: 501
          group: 0
          type: "file"
          writable: true
          readable: true
          executable: false
          file: true
          dir: false
          link: false
        }
      ]
    ]
  }

Server:

+files: Symfony\Component\HttpFoundation\FileBag {#56 ▼
    #parameters: []
  }

The other fields get returned, and end up in the db. This problem is the same for the create and edit table

JasperVdV
  • 1
  • 1
  • In which path you are trying to store youe image? have you checked the permission of that folder into your server? – Chirag Chhuchha Jan 06 '20 at 13:55
  • In my local the img is stored at storage>app>public>photos. I also did chmod 777 for this folder on the server. But I guess the img doesn't reach the controller so this shouldn't matter? – JasperVdV Jan 06 '20 at 13:57
  • delete cache and check the source code of the form generated by laravel on your page – Alberto Sinigaglia Jan 06 '20 at 14:00
  • Also, check the error logs. They should have some really useful information in them. – Jay Blanchard Jan 06 '20 at 14:10
  • Ok, deleted the cache, and inspected the form. there seems to be nothing wrong. – JasperVdV Jan 06 '20 at 15:14
  • @JayBlanchard The logs in laravel don't show anything strange... I also added ```\Log::info($request->photos)```to the controller and returns ```[2020-01-06 16:19:42] local.INFO:``` – JasperVdV Jan 06 '20 at 15:23

0 Answers0