Maybe you're not the owner of that folder
How to rename a Folder with php
hi i am having trouble in renaming some folders in php. i tried rename() but it didnt worked.. can anyone help me thank you :)
probably your code doesnt have the write permission
just give the directory full permission with this command
sudo chmod 777 directory/name
@mdecooman im sorry if my question is not precise and being a newbie here...mmm how bout this, i have a function that updates the name of my category and at the same time it updates also my folder name. but the problem is i dont have any idea how to update my folder name at the same time.. and thats it i tried to use the rename() but failed...
Hi @jeimz173
Don't be sorry to be a newbie... We all are newbies but at different levels.
Ok, there are different ways to do things:
- When looking a bit more in the doc and tinkering a little with the code, you can see that Laravel uses the rename function of PHP. Like in the class vendor/laravel/framework/src/illuminate/Filesystem/Filesystem.php. It has a function move and another moveDirectory, both are wrappers around the PHP rename function. Therefore... you can rename a file or folder.
- You can think about something else like tagging your folders and changing the tags accordingly instead of touching the file structure.
- etc.
Hope it helps...
hi @mdecooman thanks for your suggestion but i tried another way and it worked for me :)
what i did is add new column to my migration and store the path to my database then i used random() string for the name of my folder so, i don't need to rename it anymore at the same time whenever i update my category
@jeimz173 Glad you found a solution that sounds more reasonable ;-)
Please or to participate in this conversation.