download via header
Posted: Tue Sep 16, 2003 10:23 am
hi,
i'm looking for a possibility to start a download.
here is my current code:
this works fine. however i'm not satisfied with that code because it seems as if the code first creates the complete file and then sends the output to the browser. then the browser starts the downloadaction and the filesize is always 1kb.
what i want the code to do is to start a normal download.
$filecontent will be created after sending the header (this is because the file is decoded from an email - $filecontent is an email-attachment).
what i've tried out is adding flush(); after sending the header. i thought the browser would start the download dialog - however it doesn't!
is there an additional header-tag that might help me? i've read something about "content-size: filesize($file)". but i don't believe that this might help me!
greets micrix
i'm looking for a possibility to start a download.
here is my current code:
Code: Select all
header("Content-Type: $_contenttype");
header("Content-Disposition: attachment; filename="$_filename"");
// flush();
echo $filecontent;what i want the code to do is to start a normal download.
$filecontent will be created after sending the header (this is because the file is decoded from an email - $filecontent is an email-attachment).
what i've tried out is adding flush(); after sending the header. i thought the browser would start the download dialog - however it doesn't!
is there an additional header-tag that might help me? i've read something about "content-size: filesize($file)". but i don't believe that this might help me!
greets micrix