This question is an extension of https://www.experts-exchange.com/questions/29227591/php-download-file-program-not-working.html
The Expert who was helping me with this has become unresponsive.
In essence, when I rent the attached php script in a sub folder one level down from public_html, it does not work.
If I run it at the root (public_html) it works perfectly.
Why is that?
if (file_exists($path )) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($path ).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path ));
readfile($path );
exit;
}
See readfile().
OUTPUT: nf = 4
file = doc_files/LS-912-eTCX-IOM-11-2019.pdf
file = doc_files/184853_eTCX_0610_EFS_208v.pdf
file = doc_files/LS-910_eTCX_System_Brochure.pdf
file = ../pselsumms/46619summarynl.pdf
fn = 46619summarynl.pdf
path = zips/46619zip.zip
The folder zips is there, dev/zips
$path = "zips/" . $zipname;
Which implies there should be a zips folder in the script root (the folder that contains the folder download_simple.php )$_GET['files'];
The ob_get_clean () function returns the contents of the output buffer and then deletes the contents from the buffer.Seems like you're killing your output buffer. Why? Consider, the may be not send at that moment.
A018504.pdf~A018550.pdf~A018745.pdf
You are specifically excluding$file != 'doc_files/';
Which does not make sense as this is going to find files called doc_files/ which is odd - is this mean to exclude files in that folder?
I would check the privileges of the folder or if the file already exists and can't be replaced.