Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-19-2011, 08:41 AM   PM User | #1
tundoopani
New to the CF scene

 
Join Date: Jul 2011
Location: California
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tundoopani is an unknown quantity at this point
File ownership after file upload/move via PHP

I have set up a simple PHP uploader script that moves uploaded files via move_uploaded_file(). The process script does a number of checks on the uploaded files, creates a new directory (mkdir()) and then moves the file from the /tmp folder to the final destination (the new directory). The problem is my inability to delete or remove these files after the files are uploaded. I am faced with a 550 error whenever I try to delete anything.

The created directory has chmod permissions 0777 and the uploaded files have permissions 0666 (I've tried 0644). My FTP program says that these uploaded files have owner/group "48 48" whereas all other files on the system are "1006 1006". I have done some research on this issue but I have not found out much. I believe there is something wrong with these files' owner/group. These settings might be set in accordance with apache, perhaps?

I have specified chmod permissions in mkdir() and chmod() is run after each file is uploaded to change it's permissions. I have tried using copy() in place of move_uploaded_file() without any luck. What can I do to make sure these files have the correct owner/group and are able to be deleted and viewed?

Thank you in advance!

tundooPani
tundoopani is offline   Reply With Quote
Old 07-19-2011, 07:46 PM   PM User | #2
gvre
Regular Coder

 
Join Date: May 2011
Posts: 214
Thanks: 1
Thanked 50 Times in 49 Posts
gvre is an unknown quantity at this point
Could you post the code that calls mkdir() and chmod()?
gvre is offline   Reply With Quote
Old 07-19-2011, 09:43 PM   PM User | #3
tundoopani
New to the CF scene

 
Join Date: Jul 2011
Location: California
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tundoopani is an unknown quantity at this point
The code isn't anything too fancy.

PHP Code:
if(!file_exists($savedir)) {
     
$makedir mkdir($savedir0777);

$savedir is in the form of /full/path/to/new/directory

PHP Code:
$movethis move_uploaded_file($tmp_name,$newdestination);
chmod($newdestination0666); 
At this point, I am 100% certain this problem has to do with apache being the owner of the file.

Last edited by tundoopani; 07-19-2011 at 10:55 PM..
tundoopani is offline   Reply With Quote
Old 07-20-2011, 08:17 AM   PM User | #4
gvre
Regular Coder

 
Join Date: May 2011
Posts: 214
Thanks: 1
Thanked 50 Times in 49 Posts
gvre is an unknown quantity at this point
There is nothing wrong with owner/group (48 is the uid/gid of apache).
You cannot change the owner/group of uploaded file.
With 0666 perms you shouldn't have problem to view and delete the files.
gvre is offline   Reply With Quote
Reply

Bookmarks

Tags
chmod, file, permissions, php, upload

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:19 AM.


Advertisement
Log in to turn off these ads.