rename a directory or a file
24,993
Solution 1
Laravel Docs
The move method may be used to rename or move an existing file to a new location:
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
Solution 2
You can rename directories using
Storage::rename('oldFolder/', 'newFolder/');
Related videos on Youtube
Author by
Juliver Galleto
Will I am just a just a just a just simple man who loves to code around. :D
Updated on October 09, 2022Comments
-
Juliver Galleto over 1 year
I'm using Laravel 5.0 Facades Storage
use 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.
Any help, ideas, clues, suggestions, recommendations on how to rename a file or folder using the Storage?
-
Juliver Galleto almost 8 yearsi see, in php it could be like 'rename(oldname,newname,context)' so I'm looking for Laravel's way, anyway, thanks for the answer, how can I rename the file without moving it?
-
Achraf Khouadja almost 8 yearsi will edit answer,, actualy its easy check edit (i just tested the answer and it works 100% )
-
eskimo over 3 yearsWas looking for an answer to this question. Both using
rename
andmove
for renaming a folder doesn't work. Any ideas?