header() issues
| From: | Greg Donald | Date: | Sun, 08 Oct 2000 20:16:01 +0000 |
| Subject: | header() issues | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-19112@lists.php.net to get a copy of this message | ||
I'm having some problems with forced download headers.
I send the $Version and $Format variables via a form to this script listed
below.
The download starts but it has no file extension, nor is the content
correct. The file is always named something wierd like cce416ec or 4902c2c9
depending on which $Format I choose in my submitted form.
I have pretty much the same Version and Format scheme setup to feed the same
files to a php mail class as a file attachment, and that works just fine. I
just can't get these download headers to work right though.
<?
if($Format == "Unix"){
$ext = ".tar.gz";
$content_type = "application/x-gzip";
}
if ($Format == "Windows"){
$ext = ".zip";
$content_type = "application/x-zip-compressed";
}
$filename = "/home/src/file_v$Version$ext";
$short_filename = "file_v".$Version.$ext;
header("Content-Type: $content_type; name=$short_filename");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=$filename");
?>
I've been looking through php mail archives all day. There are so many
different opinions about how to do this, but none work for me. Any
suggestions?
Thanks,
Greg