move_uploaded_file(): 无法在 Laravel 8 中将'C:xampptmpphp4496.tmp'移动到'public/upload/member_new



我试过了。

if ($imageimage) {
if ($member->image != null) {
@unlink($member->image);
}
$image_name = Str::random(10);
$ext = strtolower($imageimage->getClientOriginalExtension());
$image_name = $image_name . '.' . $ext;
$upload_path = 'public/upload/member_new/';
$image_description = $upload_path . $image_name;
$imageimage->move($upload_path, $image_name);
if ($ext=='jpg' || $ext=='png'|| $ext=='jpeg'){
$member->image = $image_description;
dd('success');
}else{
Toastr::error('message', 'Image is not valid!!');
return redirect()->back();
}
}

无法移动文件"C:xampptmpphp4496.tmp"公共/上传/member_new BOm3f0T1kL.png"(move_uploaded_file():无法将'C:xampptmpphp4496.tmp'移动到'public/upload/member_new bom3f0t1kll .png').

您应该使用储存库。https://laravel.com/docs/8.x/filesystem specifying-a-file-name

$request->file->storeAs($path, $file_name, $disk);

最新更新