Protected File Download Script. Almost there

后端 未结 4 1357
無奈伤痛
無奈伤痛 2021-02-11 08:55

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

4条回答
  •  借酒劲吻你
    2021-02-11 09:08

    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.

提交回复
热议问题