[solved]problem with download script (something wron with output buffering)
Posted: Mon Jul 30, 2007 4:34 pm
Hi.
I'm making module and I have there action to download a file from serwer (action.get_prof_file.php).
Every file I downloaded using this script contain some part of html code of my page but file i uploaded are normal files not html code. I really don't know what's wrong. I tried to clear outpu buffer but this didn't make any changes :/ pls help
PS. path to downloaded file (in $file_path variable) is correct and file exists and is readable. This part of code is mostly copied fromĀ Uploads module and in upload module download works perfect.
PS2 sorry for my poor english
I'm making module and I have there action to download a file from serwer (action.get_prof_file.php).
Code: Select all
..................
if(ini_get('zlib.output_compression')){
ini_set('zlib.output_compression', 'Off');
}
@ob_clean();
@ob_clean();
if(!file_exists($file_path) || !is_readable($file_path)) die("File can't be readable");
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private',false);
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: '.filesize($file_path));
header('Content-Disposition: attachment; filename="'.$row['oryginal_name'].'"');
readfile($file_path);
exit;
PS. path to downloaded file (in $file_path variable) is correct and file exists and is readable. This part of code is mostly copied fromĀ Uploads module and in upload module download works perfect.
PS2 sorry for my poor english