1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

HostGator + FWrite = Permission Errors?

Discussion in 'PHP & Perl' started by gimme4free, Apr 5, 2009.

  1. gimme4free

    gimme4free Executive VIP Jr. VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,884
    Likes Received:
    1,932
    I get permission errors when trying to use fwrite() with my HG account.

    Directory + file are CHMOD 755 as HG do not allow 777 and if you try it you encounter server problems.

    So does this make it impossible to use fwrite with HG? I cannot seem to get it to work anyway :S
     
  2. drdankmendez

    drdankmendez Junior Member

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    316
    Location:
    In front of my computer
    I have not used hostgator before, but I have run into similar issues on standard LAMP environments. Pretty much the issue is that the php user is different than the FTP user, so when a file is uploaded via FTP it is assigned to the FTP user, when PHP tried to access it and the chmod isn't allowing 'everyone' (777) to write to the file the server sees this as a user who does not have access.

    There are a couple ways around this. If you actually create the file using PHP it should asign PHP as the file owner and chmod 755 should work. If I remember correctly you can just use a form and php to upload the file instead of using php to create and write the file directly.

    Other option would be if you had shell access, you can change the owner of the file to the PHP user.

    I am not sure if this is the same issue on hostgator, but I hope it helps.
     
    • Thanks Thanks x 1
  3. zappak

    zappak Junior Member

    Joined:
    Mar 8, 2007
    Messages:
    101
    Likes Received:
    9
    Well, Hostgator allows 777 permissions, Login from filezilla and do it, Without 777 you can't write in file at all
     
  4. gimme4free

    gimme4free Executive VIP Jr. VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,884
    Likes Received:
    1,932
    HG don't allow CHMOD 777. If you CHMOD 777 any file then you will get errors come up on the page when you try to load it. I spoke to their staff and they said that you need to submit support tickets. I'm switching to a VPS instead now to save a bit of time.
     
  5. zappak

    zappak Junior Member

    Joined:
    Mar 8, 2007
    Messages:
    101
    Likes Received:
    9
    oh ya, i mean you can't chmod root directory, but you can make temp directory, upload file there which needed to be work, and work with them in php.
     
  6. shade

    shade Junior Member

    Joined:
    Jan 1, 2009
    Messages:
    137
    Likes Received:
    179
    Occupation:
    Job? Whats a job?
    Location:
    America
    Home Page:
    What? A host not allowing CHMOD to 777? I'd ditch them fast.