php download problem.
- From: "kevinm3574" <kevintm@xxxxxxxxxxxxx>
- Date: 30 Aug 2005 11:56:11 -0700
Got the following to pop a download dialogue:
$p = explode('.', $file);
$pc = count($p);
//send headers
if(($pc > 1) AND isset($mimetype[$p[$pc - 1]]))
{
//display file inside browser
header("Content-type: " . $mimetype[$p[$pc - 1]] . "\n");
}
else
{
//force download dialog
header("Content-type: application/octet-stream\r\n");
header("Content-disposition: attachment;
filename=\"$file\"\r\n\r\n");
header("Content-transfer-encoding: binary\r\n");
header("Content-length: " . filesize($path) . "\r\n");
}
$fp=fopen($path, 'rb');
fpassthru($fp);
fclose($fp);
Download dialogue pops just fine and the file gets saved. However,
without fail, the file is 2 bytes larger than the source file. I'm
stumped. Any ideas?
Thanks.
Kevin
.
- Follow-Ups:
- Re: php download problem.
- From: Andy Hassall
- Re: php download problem.
- Prev by Date: Re: faking session data
- Next by Date: Re: Recommend good php editor
- Previous by thread: Recommend good php editor
- Next by thread: Re: php download problem.
- Index(es):