2013-02-14 45 views
1

我想用laravel 3上传多个文件到服务器,但是怎么做? 查看代码:如何上传多个文件laravel 3?

{{ Form::open_for_files() }} 
    {{ Form::label('imgs', 'Image') }} 
    <input name="imgs[]" type="file" multiple="" /> 

    {{ Form::label('', '') }} 
    {{ Form::submit('submit', array('class' => 'submit')) }} 
{{ Form::close() }} 

路线代码:

Input::upload('imgs', 'public/uploads' , 'abc.jpg'); 

,但它无法正常工作。 有人请帮忙。

回答

6

我想,你应该这样做在foreach循环是这样的:

$files = Input::file(); 
foreach($files as $key=>$file) 
{ 
    Input::upload("imgs[$key]", 'public/uploads' , "img_$key.jpg"); 
} 
2

这是我做我的应用程序(由symfony中的HTTP基础处理)

foreach((array) Request::foundation()->files->get('file') as $file) { 

    $file->move('save_path', 'new_name'); 

} 

名上传字段应该是'name ='文件[]“'