Jump to content

Uploaded File Permissions...


njdubois

Recommended Posts

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,

Nick

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.