Ruk*_*tel 2 php laravel laravel-5.1 laravel-5.2
在laravel 5.2中,我可以使用下面的代码上传文件,但找不到在数据库中存储上传文件名的方法.
$destinationPath = "test/";
$file = $request->file('profile_pic');
if($file->isValid()){
$file->move($destinationPath, $file->getClientOriginalName());
$user = User::findOrFail(Auth::user()->id);
$input = $request->all();
$input['profile_pic']->pathname = $destinationPath.$file->getClientOriginalName();
$user->update($request->all());
}
Run Code Online (Sandbox Code Playgroud)
有谁知道如何在db中存储文件名?
用于上载文件/图像和将实名写入数据库的代码
public function store(Request $request)
{
$data = $request->all();
if($file = $request->file('your_file')){
$name = $file->getClientOriginalName();
$file->move('folder_where_to_save', $name);
$data['your_file'] = $name;
}
Model_name::create($input);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11543 次 |
最近记录: |