Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Location
    California
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2

  • #3
    New to the CF scene
    Join Date
    Jul 2011
    Location
    California
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    May 2011
    Posts
    240
    Thanks
    1
    Thanked 56 Times in 55 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •