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:
SymfonyComponentHttpFoundationInputBag {#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
2
Answers
I figured it out after https://stackoverflow.com/users/23286287/bhumika-khakhadiya
Got me on the right track.
With that I now have access to the foldernames!
$files = Input::file(‘request’)[files]; foreach($files as $file) { $file; }