PHP/Linux File Permissions

Posted by user1733435 on Server Fault See other posts from Server Fault or by user1733435
Published on 2012-10-17T19:30:09Z Indexed on 2012/10/17 23:04 UTC
Read the original article Hit count: 506

Filed under:

May I ask a question about file permission. I set up Ubuntu server where Apache got running. I have simple php upload form and able to upload file to /var/www/site/uploads as follows.

sandbox@sandbox-virtual-machine:/var/www/site/uploads$ ll
total 1736
drwxrwxrwx 2 www-data www-data    4096 Oct 18 02:53 ./
drwxrwxrwx 3 sandbox  sandbox     4096 Oct 18 00:42 ../
-rw-r--r-- 1 www-data www-data  145998 Oct 18 02:53 3d wallpaper pic.jpg
-rw-r--r-- 1 www-data www-data  166947 Oct 18 02:53 3D Wallpapers 9.jpg
-rw-r--r-- 1 www-data www-data 1451489 Oct 18 02:53  
 6453_3d_landscape_hd_wallpapers_green.jpg

Is there anyway to upload files and they show up as

-rw-r--r-- 1 sandbox sandbox  145998 Oct 18 02:53 3d wallpaper pic.jpg
-rw-r--r-- 1 sandbox sandbox  166947 Oct 18 02:53 3D Wallpapers 9.jpg
-rw-r--r-- 1 sandbox sandbox 1451489 Oct 18 02:53     
 6453_3d_landscape_hd_wallpapers_green.jpg

so that I could straight away feed them to waiting/running shell script. Right now waiting script(move,checksums,rename,resize,etc) unable to do anything to uploaded files with attributes of www-data. If I just do as local account, such as

sandbox@sandbox-virtual-machine:/var/www/site/uploads$touch testfile

then the script is able to run as I would like to. Any suggestion would be grateful,thanks in advance as well.

Thanks for everyone giving help to me,that I was able to progress.

Now I am close to getting solved and append the output

sandbox@sandbox-virtual-machine:/var/www/site/uploads$ ll
total 388
drwxrwxrwx 2 www-data www-data   4096 Oct 18 04:22 ./
drwxrwxrwx 3 sandbox  sandbox    4096 Oct 18 04:17 ../
-rw-r--r-- 1 sandbox  sandbox  166947 Oct 18 04:21 3D Wallpapers 9.jpg
-rw-r--r-- 1 sandbox  sandbox  219808 Oct 18 04:20 adafruit_pi.png
-rw-rw-r-- 1 sandbox  sandbox       0 Oct 18 04:22 test

How may I set permission to uploaded files like 'test' only w difference in middle group. Such as adafruit_pi.png Vs test. Which statement shall I insert to php code,please?

© Server Fault or respective owner

Related posts about php