Php Laravel 5在表单内上传多幅图像,并将img位置保存在DB中

Php Laravel 5在表单内上传多幅图像,并将img位置保存在DB中,php,mysql,forms,file-upload,laravel-5.2,Php,Mysql,Forms,File Upload,Laravel 5.2,我有表格,里面有文本字段、复选框、选择和文件上传。我需要的是只上传图像,并将图像的位置传递给控制器,以便我可以将它们保存到db 这是我的控制器: public function spremi(){ $input= Request::all(); Oglas::create($input); return redirect('other'); } 路线: Route::post('other', 'OglasController@spremi'); 如果我

我有表格,里面有文本字段、复选框、选择和文件上传。我需要的是只上传图像,并将图像的位置传递给控制器,以便我可以将它们保存到db

这是我的控制器:

    public function spremi(){

    $input= Request::all();
    Oglas::create($input);
    return redirect('other');
}
路线:

Route::post('other', 'OglasController@spremi');

如果我返回请求,或者为我的数据库创建“Oglas”,我得到的只是图像名。而且图像没有上传到任何地方?(如存储/、公共/…)

我的问题是:如何使事情以最好的方式进行,所以我的图像被上传到一个文件夹中,并且只有它们的正确位置被保存在数据库中


提前感谢大家。

这是当时针对1个图像移动/上传进行的测试:

    $image = $request->file('slike');
    $destinationPathImg = '/your path/images/';

    if (!$image->move($destinationPathImg, $image->getClientOriginalName())) {
        return 'Error saving the file.';
    }
您的表单需要有多部分/表单数据:

{!! Form::open(['url'=>'/other','enctype'=>"multipart/form-data"]) !!}
你可以看到:
{!! Form::open(['url'=>'/other','enctype'=>"multipart/form-data"]) !!}