我想用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');
但它不起作用。 请有人帮忙。
答案 0 :(得分:6)
我认为,你应该在foreach循环中这样做:
$files = Input::file();
foreach($files as $key=>$file)
{
Input::upload("imgs[$key]", 'public/uploads' , "img_$key.jpg");
}
答案 1 :(得分:2)
这就是我在我的应用程序中所做的事情(由symfony的http基础处理)
foreach((array) Request::foundation()->files->get('file') as $file) {
$file->move('save_path', 'new_name');
}
上传字段的名称应为'name =“file []”'