Jump to content


Uploaded File Permissions...

  • Please log in to reply
2 replies to this topic

#1 njdubois


    Advanced Member

  • Members
  • PipPipPip
  • 194 posts

Posted 26 November 2012 - 04:14 PM

I've been having an issue with files I upload via a webpage and php. Everything works, but I can't get the permissions to be setup right.

I know my code is working. I have used the same exact code for 2 other clients with godaddy. The default permisson for files uploaded with godaddy is:

The folder itself:
rwx---r-x (0705)

A file in the folder:
rw-r--r-- (0644)

And everything works fine. On this clients host www.networksolutions.com:

The folder itself:
rwxrwsr-x (2775)

A file in the folder:
rw-r----- (0640)

These are all defaults, I have never changed anything with the the clients on godaddy.

I've read all over, the same issues. Broken Image Link on site, you can manually download the file from an ftp client and everything is ok. Most of these sites say changing the permissions on the folder itself should solve the problem. It doesn't matter what I change it to, the uploaded files still have the same permissions?

The support specialist...if that's what you want to call him... says that the server is configured properly, and that I have to use a script that "uses ch-mod to change permissions of uploaded file." I'm sure I can figure this out no problem. I don't see why I have to. Isn't there a setting somewhere I can change? I contacted them, networksolutions, first because they are a smaller host, and I figured there wasn't much anyone here would be able to do for me. I remember reading somewhere that there is config files stored in the root folder of the server that I may be able to setup default permissions and thus have what I have already done and working everywhere else do just that, work.

I understand that as a web developer I am going to have to learn the ch-mod stuff sooner than later. I read somewhere that you can use that to send out mass emails on hosts with over shared email servers. (can only send so many at a time) So whats the plan? Should I start working on that now, or is there something I can do to make what I know works, work?

Thanks for your time friend,

#2 njdubois


    Advanced Member

  • Members
  • PipPipPip
  • 194 posts

Posted 26 November 2012 - 04:52 PM

an update.....

chmod($target_path, 0755);

works fine. But I'd still like to know if there is a way to handle this server side?


#3 requinix


    Subconscious Administrator

  • Administrators
  • 7,613 posts
  • LocationWA

Posted 26 November 2012 - 06:29 PM

But I'd still like to know if there is a way to handle this server side?

You just showed how to do that: call chmod() on the file. Apparently it's necessary...

Normally the web server is running as a different user than the account owner, like "apache" versus "njdubois". Given that situation I can think of at least three different ways to manage permissions on uploads:
1. Directory is owned by apache:apache and 0755/0775, files are owned by apache:apache and 0644/0664
2. Directory is owned by njdubois:yourgroup and 0777, files are owned by apache:apache and 0644/0664
3. Directory is owned by njdubois:yourgroup and 2777, files are owned by apache:yourgroup and 0644/0664
Note that the directory is owned by either you or apache and the files are always owned by apache. No alternatives. You shouldn't need to change permissions on the uploaded files unless there's some unusual umask set and you don't have u+rw g+r/rw o+r by default (and even then you might not have to do anything).
Monkeys on typewriters may have a hard time writing Shakespeare, but they sure had no problem writing IP.Board.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users