Friday, April 2, 2010

PHP File upload paths

Hello,

I am curious about file upload paths in php.?Can you set path relative to the website??From what I am reading it seems relative to the computer.?So when I move the site to a web server, all those instances of the upload path will have to change.

PHP File upload paths

Where are you setting the path? Usually you'd use a variable, like:

$uploadDir = $_SERVER['DOCUMENT_ROOT'].''/path/to/uploads'';

...so it's relative to the site's document root.

PHP File upload paths

I am new to PHP and the book didn't mention the $_SERVER global.?I will have to take a look at that!?Thank you!

You're welcome - here's more info from php.net if you haven't already found it:

http://us.php.net/manual/en/reserved.variables.server.php

The $_SERVER global variable replaced $HTTP_SERVER_VARS from previous versions (3-). There's a lot of info in that array, and 'DOCUMENT_ROOT' is a handy way to grab a dynamic reference to the full server path to things within the web root.

  • skin blackheads
  • No comments:

    Post a Comment