SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    May 2004
    Location
    London
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    can't set directory permissions from within my script

    Hi there

    I've written a membership registration script for my site and it works fine....

    In amongst the whole routine I wanted a directory to be created for that member so he can upload photos to it....the name for this directory would be the number that get's generated by the database for that member.

    So this is the code I used to achieve that

    Code:
    $last_id = mysql_insert_id();
    
    $thumbnails = "photos/thumbnails/" . $last_id;
    $full = "photos/full/" . $last_id;
    
    if(!file_exists($thumbnails))
      {
        mkdir("$thumbnails", 0777);
      } 
    
    if(!file_exists($full))
        {
           mkdir("$full", 0777);
        }
    The problem is that whilst the directories are created the permissions for them are not set to 777 they are set to 666 only, when a member goes to upload a photo this is the error message they get...


    Warning: copy(photos/full/16/marina2.jpg) [function.copy]: failed to open stream: Permission denied in /home/juan/public_html/site/members/upload.php on line 112

    If I manually set the permissions myself to 777 then the member can upload fine. Obviously I need the script to set permission to 777. Why is this? Can anyone please help.

  2. #2
    hi galen's Avatar
    Join Date
    Jan 2006
    Location
    New Haven, CT
    Posts
    1,228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try putting
    Code:
    umask(0);
    before your mkdir functions

  3. #3
    SitePoint Addict
    Join Date
    Aug 2007
    Location
    GR
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    create the directory and then do a chmod() from your code.


Bookmarks

Posting Permissions

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