Search code examples
phplaravelfile-uploadfilepond

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


Solution

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