Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rename a directory or a file

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?

like image 645
Juliver Galleto Avatar asked Jun 01 '16 01:06

Juliver Galleto


People also ask

Can you rename a directory?

You rename a directory by moving it to a different name. Use the mv command to rename directories. You can also use mv to move a directory to a location within another directory.

Which command do you use to rename files and directories?

Use the mv command to move files and directories from one directory to another or to rename a file or directory.


2 Answers

You can rename directories using

Storage::rename('oldFolder/', 'newFolder/');
like image 51
Gilson Urbano Avatar answered Sep 28 '22 08:09

Gilson Urbano


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 

Source

like image 23
Achraf Khouadja Avatar answered Sep 28 '22 07:09

Achraf Khouadja