簡體   English   中英

laravel 3如何上傳多個文件?

[英]How upload multiple files 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');

但它不起作用。 有人幫忙。

我認為,您應該在foreach循環中執行以下操作:

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

這就是我在應用程序中所做的(由symfony的http基礎處理)

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

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

}

上傳字段的名稱應為“ name =“ file []””

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM