i want to upload multiple files to server with laravel 3 but how? View code:
{{ Form::open_for_files() }}
{{ Form::label('imgs', 'Image') }}
<input name="imgs[]" type="file" multiple="" />
{{ Form::label('', '') }}
{{ Form::submit('submit', array('class' => 'submit')) }}
{{ Form::close() }}
Routes code:
Input::upload('imgs', 'public/uploads' , 'abc.jpg');
but it is not working. anybody help please.
I think, you should do it in foreach loop like this:
$files = Input::file();
foreach($files as $key=>$file)
{
Input::upload("imgs[$key]", 'public/uploads' , "img_$key.jpg");
}
This is what I did in my app, (handled by symfony's http foundation)
foreach((array) Request::foundation()->files->get('file') as $file) {
$file->move('save_path', 'new_name');
}
name for upload fields should be 'name="file[]"'