skip to Main Content

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


  1. Chosen as BEST ANSWER

    I figured it out after https://stackoverflow.com/users/23286287/bhumika-khakhadiya

    Got me on the right track.

        $files = $request->input('files');
        $tmpFiles = TemporaryFile::whereIn('folder', $files)->get();
        $folderNames = $tmpFiles->pluck('folder')->toArray();
    

    With that I now have access to the foldernames!


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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search