【发布时间】:2018-03-22 15:11:04
【问题描述】:
我从这里看到:rename a directory or a file
我尝试这样:
$destination_path = public_path() . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'products'. DIRECTORY_SEPARATOR . $product->id . DIRECTORY_SEPARATOR . $product->photo;
$new_file_name = public_path() . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'products'. DIRECTORY_SEPARATOR . $product->id . DIRECTORY_SEPARATOR . $new_file_name;
// dd($destination_path, $new_file_name);
Storage::move($destination_path, $new_file_name);
存在错误:
[League\Flysystem\FileNotFoundException] 在路径中找不到文件: C:/xampp/htdocs/myshop/public/img/products/147/Zl756CDHovOZpEZz0jBYk73UCfO4zNmYDVWgLPpw.png
如果我 dd($destination_path, $new_file_name),结果:
C:\xampp\htdocs\myshop\public\img\products\147\Zl756CDHovOZpEZz0jBYk73UCfO4zNmYDVWgLPpw.png
C:\xampp\htdocs\myshop\public\img\products\147\147-hazard-chelsea.png
我尝试检查文件夹 147 中的 Zl756CDHovOZpEZz0jBYk73UCfO4zNmYDVWgLPpw.png,该文件存在
为什么会出现错误?
更新:
我找到了解决方案。我使用这样的 php 脚本:
rename($destination_path, $new_file_name);。有效
【问题讨论】:
-
有没有人帮忙?
-
请检查 dd(\Storage::exists($destination_path));
-
存储使用C:/xampp/htdocs/myshop/storage/app
-
@honarkhah,如果我这样做
dd(\Storage::exists($destination_path));,结果:false
标签: image laravel laravel-5.3 filenames file-rename