Forum Moderators: coopster

Message Too Old, No Replies

Error deleting uploaded files

Error deleting uploaded files

         

danyc

9:27 am on May 3, 2005 (gmt 0)

10+ Year Member



Hello!
I'm a student learning PHP, so not an expert ... yet ;)
I have a configuration script which creates a directory on the server, directory used for uploading files. Everything works fine (creation of the directory, uploading) but when I try to delete an uploaded file from this directory using total commander as ftp client I get the following error: "550 Delete operation failed".

The used code is something like this:

$cursuri = "../cursuri";
@mkdir($cursuri, 0777);

Note: if I use total commander "chmod 777 cursuri" I don't get any problems.

Can somebody tell me where I'm wrong and offer a better solution, please?
Thank you.

jusdrum

4:41 pm on May 3, 2005 (gmt 0)

10+ Year Member



You chmod'd the directory correctly, but anything inside the directory will not be chmod'd to 0777 and will retain the permissions that were originally set when it was uploaded. You have to apply chmod 0777 to each file in the directory as well.

jatar_k

9:09 pm on May 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld danyc,

there is a recursive chmod function in the user comments on this page
[php.net...]

normally when issuing the proper command via the command line it would be something like

chmod -R 777 mydir

then all files get the appropriate permissions.

Another option might be to delete these files via a script which will also work.

danyc

9:25 am on May 4, 2005 (gmt 0)

10+ Year Member



Thank you for replies, but I've figured out the problem.
Although I used @mkdir($cursuri, 0777) the folder permissions were 755. Now I'm using:

umask(0);
@mkdir($cursuri, 0777);

and works fine.
Another problem occured now :D. On another server safe_mode is on; I want to create a file (user inputs some data and this data is stored in a file from a 777 folder.
Because of safe_mode on I get the following error:
"fopen() [function.fopen]: SAFE MODE Restriction in effect. The script whose uid/gid is 10187/10187 is not allowed to access /..../Folder owned by uid/gid 99/503"

Is there a way of avoiding this error and create the file?

jatar_k

4:46 pm on May 4, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if the directory wasn't created by a script, maybe try doing that.