Jump to content

PHP code to trigger file download


cbassett03

Recommended Posts

How can I create a PHP script that will trigger a download?

 

For example, if I have a database of files and file IDs, and have a hyperlink like this in an HTML page:

 

getfile.php?FileID=1001

 

How can I code the getfile.php file so that no matter what type the file is (ZIP, EXE, JPG, AVI, etc), it will cause the browser to prompt the user to download the file?

 

(Not entirely sure if this is more a PHP question or an HTML question because of how I'm approaching it...)

 

(The purpose of me using the getfile.php file is so that files can be physically moved around without me having to update all of the hyperlinks in the HTML files, but rather just update the paths in the SQL database instead.)

Link to comment
https://forums.phpfreaks.com/topic/290816-php-code-to-trigger-file-download/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.