laravel - move_uploaded_file():无法在 Laravel 8 中将 'C:\xampp\tmp\php4496.tmp' 移动到 'public/upload/member_new\BOm3f0T1kL.png'
问题描述
我试过这样。
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:\xampp\tmp\php4496.tmp”移动到“public/upload/member_new\BOm3f0T1kL.png”(move_uploaded_file(): Unable to move 'C:\xampp\tmp\php4496.tmp' to '公共/上传/member_new\BOm3f0T1kL.png')。
解决方案
你应该使用存储 laravel。 https://laravel.com/docs/8.x/filesystem#specifying-a-file-name
$request->file->storeAs($path, $file_name, $disk);
推荐阅读
- python - 在 Pyomo 中实现 MINLP 求解器“apopt”
- flutter - Flutter - 找不到正确的提供者
在此 ChangeLocation 小部件上方 - python - 我正在尝试将函数 compute() 拆分为 2 个单独的函数
- basic - 做什么 ”!” 和 ”。” 在 BASIC 中是什么意思?
- python - 为什么 Databricks 笔记本单元一直在训练我的 ML 模型“正在运行命令……”?
- python - 有什么方法可以将 GAE 应用程序与自定义谷歌云数据库连接起来?
- reactjs - 在 NextJS 应用程序中使用 Cypress 组件测试
- c# - Blazor WASM 中的 MudSelect 问题
- java - 带有环境变量的 Dockerized Spring 应用程序
- wpf - 如何在 WPF 中将子项添加到 ItemsControl 的 ItemsPanelTemplate?