I've written a download script to deal with downloading multiple different documents from a querystring variable.
This works fine, my problem comes when I come to download.
I have a specific directory
$file = 'test/file.pdf';
switch($extension)
{
case eps: # EPS
header('Content-type: application/postscript ai eps ps');
break;
case jpg: # JPEG
header('Content-type: image/jpeg jpeg jpg jpe');
break;
case pdf: # PDF
header('Content-type: application/pdf');
break;
default:
echo $error;
break;
}
// Append file location with the filename
$file = $file_location.$file;
// Commence Download
header('Content-Disposition: attachment; filename='.$file.'');
// Specify source of files to be read
readfile($file);
I keep getting corrupted documents as the file being downloaded is called test-file.pdf
As opposed to test/file.pdf, is there a better way I can point the script to the directory I want to download from???