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=\"$fil e\"\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
$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=\"$fil e\"\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
Comment