Yet another downloader problem
Posted: Thu Apr 07, 2005 5:58 am
Hello and thanks...
I have a download script that has worked fine for some time, but now I am having problems. It will download pdf's fine, but when I try to download a csv file, I get zero file size, yet the actual file on the server is full and right.
After doing a bit of searching here, I tried varying the content-type for the csv, but it doesn't help.
I've been using Firefox 1.0 Mac as my testing browser. This is being used on an intranet and that's their browser.
Here is the code:
Thanks,
- dstefani
I have a download script that has worked fine for some time, but now I am having problems. It will download pdf's fine, but when I try to download a csv file, I get zero file size, yet the actual file on the server is full and right.
After doing a bit of searching here, I tried varying the content-type for the csv, but it doesn't help.
I've been using Firefox 1.0 Mac as my testing browser. This is being used on an intranet and that's their browser.
Here is the code:
Code: Select all
<?php
if($_REQUEST['d'] == 1 ) { // a csv file
$file=$_REQUEST['file'];
$root = 'path/to/my/file/';
$file_to_download = $root.$file;
$type = 'text/csv';
}
else { // anything else
$root = 'path/to/my/file/';
$file=$_REQUEST['file'];
$file_to_download = $root.$file;
$type = 'application/octet-stream';
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header ('Content-Disposition: attachment; filename='.$file);
header( "Content-Description: File Transfer");
@readfile($file_to_download);
?>- dstefani