• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

PHP File Uploading

Hi

I have a script which allows users to upload files through a web form to my server, however, I realised that all the files that are uploaded have a default permission attribute of "600". These files should actually be viewable by the user, which means it should be uploaded to a "644" permission.

Can someone advice me if this default permission attribute have to be made server side, or am I doing something wrong with my scripts?
0
lifegauge
Asked:
lifegauge
  • 2
2 Solutions
 
php-webdesignCommented:
after uploading set the permission right with the PHP funtion CHMOD:

http://nl.php.net/chmod
0
 
dtheminkCommented:
You could do a chmod on it just as php-webdesign has mentioned, but it would be better to set default permissions on the directory to which you're writing and for the user who is doing the writing.  Chmod is great but for security purposes, it would be better to config on the server instead of making PHP do the work.

If you are using a Linux web server you need to find out which user is writing the files (sometimes apache, sometimes nobody - depends on how the server has been config'd).  Then you can change the user's umask so that any files they write use the default permissions you've set.
0
 
php-webdesignCommented:
i know... but the CHMOD way of PHP is good to work with if you haven't got full access to the server. but if you do have full access your way is bether :)
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now