Hi,
ich kann dir ja mal zeigen, wie ich es mache:
Code:
$filename = '...';
$filename = $config_main['root'] . $filename; // absoluter Pfad
$file_size = filesize($filename);
header('Content-Type: ' . get_mime_type());
header('Content-Disposition: attachment; filename=' .
basename($config_main['root'] . $filename));
header('Content-Length: ' . $file_size);
readfile($config_main['root'] . $filename);
Die Funktion
get_mime_type() ist diese:
Code:
// get mime type for the different browsers
function get_mime_type()
{
$agent = $_SERVER['HTTP_USER_AGENT'];
if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $agent))
{
$return = 'application/octetstream';
}
else if (ereg('MSIE ([0-9].[0-9]{1,2})', $agent))
{
$return = 'application/octetstream';
}
else
{
$return = 'application/octet-stream';
}
return $return;
}
Grüße, Matze