laravel 重命名目录或文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37557903/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
rename a directory or a file
提问by Juliver Galleto
I'm using Laravel 5.0 Facades Storage
我正在使用 Laravel 5.0 Facades Storage
use Illuminate\Support\Facades\Storage;
使用 Illuminate\Support\Facades\Storage;
and I can use it like
我可以像这样使用它
Storage::..
In the Laravel 5.0 Docs,there's nothing like rename a file or folder from the storage.
在 Laravel 5.0 Docs 中,没有什么比从存储中重命名文件或文件夹更简单了。
Any help, ideas, clues, suggestions, recommendations on how to rename a file or folder using the Storage?
关于如何使用存储重命名文件或文件夹的任何帮助、想法、线索、建议和建议?
回答by Achraf Khouadja
Laravel Docs
Laravel 文档
The move method may be used to renameor move an existing file to a new location:
move 方法可用于重命名或将现有文件移动到新位置:
Storage::move('hodor/file1.jpg', 'holdthedoor/file2.jpg');
this way, you can rename without moving
这样,您无需移动即可重命名
Storage::move('hodor/oldfile-name.jpg', 'hodor/newfile-name.jpg'); // keep the same folder to just rename