SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Melbourne
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Safe mode, and managing files under it

    What is the best way to manage files stored on a server that has safe mode restrictions? Say I have a 'data' directory located on the server. When I upload a file, I want to create a new directory under the 'data' directory named after its id (ie 'data/234'). Creating that directory through php works fine, but as soon as I go to create / store a file inside that directory, php throws an error because the directory is now owned by php, whereas the scripts are owned by me. What's the best way to be able to manipulate files nicely in this sort of environment?

  2. #2
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's a solution in the comments section of the manual that you might find useful. Hope it helps.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web

  3. #3
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Melbourne
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I saw that, but it only applies to hosts with FTP enabled. I guess I'm hoping that one of the CMS developers who's handled this might be able to suggest something.

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried changing the owner of the directory?

    See: http://uk.php.net/chown

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  5. #5
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by seanf
    Have you tried changing the owner of the directory?

    See: http://uk.php.net/chown

    Sean
    A worthy thought, but I don't think it will work. According to the manual:

    If you're on a shared *nix server, a directory created through mkdir() will not be assigned to you, but to the user that your host's server or php process is running under, usually 'nobody', 'apache' or 'httpd'.
    When you use chown(), here's what happens:

    When safe mode is enabled, PHP checks whether the files or directories you are about to operate on have the same UID (owner) as the script that is being executed.
    As the script owner isn't 'nobody', 'apache' or 'httpd', using chown() won't solve the problem either.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web


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
  •