Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   Upload Permissions (http://www.programmingforums.org/showthread.php?t=15000)

kruptof Jan 22nd, 2008 12:10 PM

Upload Permissions
 
I am currently working on a project which requires the upload of files to a specific directory. It seems the only way to upload the file is to chmod the directory to 777. My question is what is the danger associated with doing that, surely having a directory that the whole world can write to is bad right? And if this approach is bad then what other ways exists to upload the files.

titaniumdecoy Jan 22nd, 2008 12:19 PM

Re: Upload Permissions
 
A common approach is to use a directory with permissions set to 777 below your web root directory (eg, if your web root is /public_html/, you might use /uploads/).

kruptof Jan 22nd, 2008 12:29 PM

Re: Upload Permissions
 
Quote:

Originally Posted by titaniumdecoy (Post 140069)
A common approach is to use a directory with permissions set to 777 below your web root directory (eg, if your web root is /public_html/, you might use /uploads/).

How can apache serve the files then, I thought it was only allowed to serve anything within or below the document root?

Sane Jan 22nd, 2008 3:40 PM

Re: Upload Permissions
 
You shouldn't have needed to do that. Make sure the username you are using is the privileged owner of the directory, when you're FTPing the files over.

Quote:

Originally Posted by kruptof (Post 140071)
How can apache serve the files then, I thought it was only allowed to serve anything within or below the document root?

I'm assuming you mean 'above'. And yes, but it's also circumstantial upon how your service has configured Apache.

kruptof Jan 22nd, 2008 3:44 PM

Re: Upload Permissions
 
I am not using an FTP client Sane. I am uploading them using a HTML Form

Sane Jan 22nd, 2008 3:50 PM

Re: Upload Permissions
 
Oh, and you've written a PHP uploader to handle the upload and save it to the current directory? Maybe you should focus on the root of the problem here: the uploader.

Is the owner of the .php script the same as the owner of the directory? I'm not exactly sure how it works, but I assume if the .php script is not the owner of the directory, then it can't write to the directory (unless it's 777).


All times are GMT -5. The time now is 4:05 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC