I am using the code below to try to initiate a download of an sql script created from the mysqldump command. I am using Apache as my webserver. Basically all it does is display the contents of the sql file in the browser (Both IE and Firefox) instead of displaying the Save / Open / Cancel dialog.
I am fairly new to this part of PHP and have tried manipulating the code via examples I found on the web with no success. Can anyone point me in the right direction?
I have tried changing the Content-Type: to different formats (application/x-download, etc) and adding set_time_limit(0); right before @readfile per some of the comments on @readfile on php.net.
I am fairly new to this part of PHP and have tried manipulating the code via examples I found on the web with no success. Can anyone point me in the right direction?
I have tried changing the Content-Type: to different formats (application/x-download, etc) and adding set_time_limit(0); right before @readfile per some of the comments on @readfile on php.net.
Code:
# Start the download process
$len = filesize($backupFile);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: application/text");
header("Content-Disposition: attachment; filename=$filename;");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$len);
@readfile($backupFile);
# Delete the temporary backup file from server
unlink($backupFile);