我正在尝试将文件路径保存到数据库并将文件移动到给定目录。文件路径已保存到数据库,但文件未上传。请帮助
我试图指定文件路径并重命名文件
这是我的控制人:
public function uploadId(Request $request)
{
$pathOne = $request->file('front_id')->move('public/verify/', 'front_id'.time());
$pathTwo = $request->file('back_id')->move('images/verify/', 'back_id'.time());
$pathThree = $request->file('address')->move('images/verify/', 'address'.time());
$identification = new Identification;
$identification->user_id = Auth::user()->id;
$identification->front_id = $pathOne;
$identification->back_id = $pathTwo;
$identification->address = $pathThree;
$identification->save();
return redirect()->back()->with("success", "Your ID's has successfully been uploaded.");
}
我希望文件被保存到数据库并上传到目录,但事实并非如此。文件路径只会保存。
答案 0 :(得分:0)
您没有将文件存储在代码中的任何位置。您无法移动尚未保存的文件。
$path = $request->file('avatar')->store('avatars');