I have a php script that goes to another url to grab a file and give the option to the user to save it. Basically we want the file to appear to download from the site they are on (nothing shady we own both sites:))
I'm using php and fopen to do this but it's failing every other or 3rd time you click the download button. It gives the stream can't be open 500 internal error.
Here is the code:
$handle = @fopen($download_url, "r");
die("Error opening file");
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="'.$download->exe_name.'"');
echo fread($handle, 1);
It's really weird since it works part of the time downloading the same file.