The title may be a little misleading, but basically I have a .php page which returns a list of files available for download.
What I want is that when the user clicks on the link to the file, they are prompted to download (regardless of file type)...
I know I need to use headers and content-disposition, but how do I include this on a page where the user may download any 1 of 50 files??
Does anyone have an example of a page they have similar to this (it must be quite common)...
Thanks in advance
Forcing file download for multiple files
Moderator: General Moderators
Re: Forcing file download for multiple files
Your link href must be download.php?file=filename.pdf
And in download.php set the headers and read the file with readfile()
Do not forget the security, someone could access the other files in your server by passing ?file=../../config.php for example, so you should check the value before to read and output the file.
And in download.php set the headers and read the file with readfile()
Do not forget the security, someone could access the other files in your server by passing ?file=../../config.php for example, so you should check the value before to read and output the file.
Re: Forcing file download for multiple files
Could you give an example of what the download.php would look like?
And it's been a while since I retrieved variables from the URl.. Do I use $_GET still?
Thanks,
Paul
And it's been a while since I retrieved variables from the URl.. Do I use $_GET still?
Thanks,
Paul