I have a file that users will purchase via paypal, clickbank and paydotcom. I have to host the file\'s download page on my server.
I\'ve placed the file in a directory o
You can use the parent directory shortcut ../
in your $path
or the dirname function like:
$parent_dir = dirname( dirname( __FILE__ ) );
// first dirname is the directory of this file, second goes up one level, etc.
BTW, beware of indicating the path in your URL, one could read other files (like configuration files or ohter private files) by changing it to download.php?download_file=../../private/bank_certificate.pem
. You should use realpath to get the absolute path of the file and compare it to an "authorized for download" file list.
Custom coding may not be the best solution these days for a file download script. Check out Drupal which has file download modules, that can be integrated with its Clickbank module as well: http://drupal.org/project/clickbank_ipn
well if public_html
is your doc root then you should be able to get the path to download would be
realpath($_SERVER[DOCUMENT_ROOT].'/../download');
You just need to consider the path like a normal directory path, not a web one. so to go up a level simply "../" e.g.
if you structure is like this
/path2file/inhere.pdf /public_html/download.php
the path to the file would simply be from download.php "../path2file/inhere.pdf"