1

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.

2 Answers 2

6

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");
}
Sign up to request clarification or add additional context in comments.

Comments

2

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[]"'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.