Problem with PHP download
Posted: Tue Feb 09, 2010 3:57 pm
Hello,
I developed a client login system and I have run into a little trouble when downloading files from the server. I am calculating the variable called $file and using the following code:
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: private');
header('Pragma: private');
ob_clean();
//flush();
readfile($file);
}
Once in a while, when someone tries to download this file, the entire folder (in which the file exists) or all the other files (including the current file) get deleted for no reason. Can someone tell me why this is happening?
Regards,
G.C.Reddy
I developed a client login system and I have run into a little trouble when downloading files from the server. I am calculating the variable called $file and using the following code:
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: private');
header('Pragma: private');
ob_clean();
//flush();
readfile($file);
}
Once in a while, when someone tries to download this file, the entire folder (in which the file exists) or all the other files (including the current file) get deleted for no reason. Can someone tell me why this is happening?
Regards,
G.C.Reddy