Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to access array of files from Laravel request

I have an Laravel request in which there is an array for uploaded files.
When doing dd($request); I get the following response for the request object.

+request: 
Symfony\Component\HttpFoundation\InputBag {#37 ▼
    #parameters: array:6 [▼
      "_token" => "0YgPQyZ6fDvKfqohFzLTrV6GVs2xLmu60Vh2H3Je"
      "_method" => "post"
      "shortdescription" => "123"
      "department" => "IT"
      "description" => "123123"
      "files" => array:2 [▼
        0 => "ticket65af9c14d6e554.69690242"
        1 => "ticket65af9c14b43675.72479216"
      ]
    ]
  }

How can I access the files inside Laravel? I already tried the following things:

$allFiles = $request->files->all();
$allFiles = $request->allFiles();
$allFiles = $request->files->get('files');
$allFiles = $request->file('files');

When I try to dd($allFiles); they are just NULL
Where am I going wrong here? I can not figure it out how to access these files

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

$files = Input::file(‘request’)[files]; foreach($files as $file) { $file; }

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading