1
votes

I have a script that uploads files to a directory with file permissions 0644. I am unable to delete the file via FTP or using PHP's unlink() function (550 error). After scouring the web, I was unable to find a method to fix this problem. I am aware that the issue has to do with group/owner permissions, but I don't know how to fix the problem.

Should I use copy() or rename() instead?

Any ideas?

Edit: All uploaded files have owner/group set as: 48 48. All other files that I have uploaded via FTP and NOT the PHP script are 1006 1006. Is the owner/group set for the incorrect user? I have already tried using chmod() to set permissions to 0666. I think the problem may be with the user?

Edit 2: Should I use exec() and run a command that changes the owner and group of the file?

3

3 Answers

0
votes

It depends on what user your script is running as. Try uploading the files as 0655 instead

0
votes

if you're using move_uploaded_file(); function, permissions are set correctly, so unlink(); should work

try this

move_uploaded_file($from, $to);
chmod($to, 0666);
0
votes

You will want to have write permission to delete the file. 6 represents read/write. The first number after the zero represents the file's owner, who created it. If you are running the script to create the file, you should be able to delete it as long as you use the same user, probably the server user.