PHP Forums Archive

Uploading a file outside the public_html root?

Tags: jquery

DavidDavid posted on 2010-06-24 21:07:47 #

Hi,

I'm trying to modify the upload_demo.php to upload files outside of the public_html directory. Is this possible?

Here's what I've tried, but it doesn't work:

$folder = $_SERVER['DOCUMENT_ROOT']."/../files/";

Any help would be appreciated :)

Comments / discussions

Olaf posted on 2010-06-25 04:27:20 #

Hi,

sure you can if you have write acccess.
echo $_SERVER['DOCUMENT_ROOT']

from your public root folder and modify the path you got and use it as your upload path

DavidDavid posted on 2010-06-25 17:28:36 #

That worked great! Thanks!

marinasos posted on 2010-07-22 11:26:04 #

method seems to be the simplest and most elegant way to protect read-only files that, for whatever reason, must be stored in public_html. In this example, we protect configuration.php, perhaps the most confidential file of any Joomla! site. Using this method, even if the Web server somehow delivers the contents of PHP files, for example due to a misconfiguration, nobody can see the contents of the real configuration file.