deleting files with delete_files() in helper |
I have two files I am trying to delete programmatically. Here is how I am doing it
$file='/app/assets/uploads/files/'.$user->file_url; $iRc=delete_files($file); //delete the pdf //delete the thumbnail $iRc=delete_files('/app/'.$user->thumbnail_url); I am running in docker. Both these deletes fail ($iRc=false). So I tried to delete from the cli and that seems to work. I did open a bin/bash session into the running container. I also took a look at the permissions and I see that although I am the owner (ME) and have read/write permissions, my application is running under group richb201 (I think) and that the group has "read only" permissions. How can I be sure that my app is under richb201, btw? How can I change the permissions programatically so that my app can rm these two. I am under Ubuntu.
proof that an old dog can learn new tricks
chmod
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
thx. I found it. But it is not working. Could be because the owner is www.
proof that an old dog can learn new tricks
Check to see if there is a .htaccess file in the app folder.
You should have the assets folder in the root along with index.php After looking at the helper what your doing is wrong the helper deletes all the files in a folder. This is what you want not tested just figure out the right path. PHP Code: $path = base_url('assets/uploads/files/').$user->file_url; What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Turned out that I didn't know how to use delete_files. It deletes all the files of a directory, when I just wanted to delete a specific file.
Here is the solution that worked. $cmd = "rm ". '/app/assets/uploads/files/'. $user->file_url; $result = shell_exec($cmd); //delete thumbnail $cmd = "rm ". '/app/'. $user->thumbnail_url; shell_exec($cmd);
proof that an old dog can learn new tricks
|
Welcome Guest, Not a member yet? Register Sign In |