How to request file with array name of input file?

use the below code, since the name attribute is an array

$files = Request::file('collateral_photo');
return $files[0];

or if you want second file

return $files[1];

//if you want to access second file and so on

you need to access the file with array index specified.

If you want to return the whole files array itself then use

return $files

And going one step further we can work with multiple-level-arrays like so:

<input name="channel[1][file]" type="file">
<input name="channel[2][file]" type="file">

in laravel you would need a structure

$files = $request->file('channel');
$file1 = $files[1]['file'];
$file2 = $files[2]['file'];

Tags:

Html

Php

Laravel