Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i rename directory in Laravel5.1

How can I rename directory on public , In my controller ? I read Laravel document but File class doesn't have rename .

File::move();

I just need rename , I cant move my files to an other Folder

like image 536
Morteza Negahi Avatar asked Mar 12 '23 22:03

Morteza Negahi


1 Answers

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 

Storage::move('hodor/old-folder-name', 'hodor/new-cool-folder-name'); //rename folder
like image 161
Achraf Khouadja Avatar answered Mar 28 '23 06:03

Achraf Khouadja