【发布时间】:2018-01-09 16:31:23
【问题描述】:
所以,我保存了存储文件,可以像这样访问它们:
$file = Storage::disk('public')->url("featured/{$i->image}")
这让我获得了我在storage/ 目录中的文件的完整 URL。我怎样才能使它可以将相同的文件复制并粘贴到新目录但使用新文件名?
我试过了:
$url = Storage::disk('public')->url("featured/{$i->image}");
$fileName = 'u_' . (new \DateTime())->getTimestamp() . '.png';
$fileDestination = '/new_folder/' . $fileName;
$i->image = $fileDestination;
File::copy($url, $fileDestination);
我收到 PHP 执行超时错误。我认为我没有正确引用路径。
我想将/storage/app/public/featured/imageOne.png复制到/storage/app/public/new_folder/imageOneWITHNEWFILENAME.png
有Storage门面解决方案吗?
【问题讨论】:
-
“但我总是遇到错误。” 比如?
-
错误是什么?
-
请显示
$newDestination变量的值 -
存储::copy($file, $newDestination);检查此链接laravel.com/docs/5.5/filesystem#storing-files
-
我已经更新了一点。