PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, January 8, 2022

[FIXED] What rights should I put on directory so web site users can upload photos?

 January 08, 2022     lamp, linux, php     No comments   

Issue

I want users to upload photos to these folders (with a PHP script)

upload/big
upload/thumb 

I guess putting '777' is risky (they could upload some PHP files etc..)

What is the rights I should put on the upload folder ?


Solution

The folders should just have their default chmod of 755. The "trick" is to set the ownership of the folders to the user that your PHP script is running under (usually www-data or apache). If you're unsure, run this simple script:

<?php
echo `whoami`;

Then, chown the folders to this user/group, for example:

chown -R www-data upload/

That will make sure that www-data will be the owner of the upload folder and it can do as it pleases inside that folder (because the owner has full permissions).



Answered By - Oldskool
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing