PDA

View Full Version : php, file download


maxelcat
September 11th, 2007, 23:20
Dear All

I want users to be able to download a file. Its all working. When the user clicks the link the windows "File download" box pops up asking if the user wants to save/open etc.

Press save and the file will save. However, the estimated time left says "Not known 1.4Mb downloaded" etc.

How do I get it to show the estimated time left - i guess its something to do with fetching the actual file size from the server???

Here is the code that I have been using so far.

thanks in advance

Edward

<?php #download sound
//has footer.html and header.html as includes

$file_name= $_GET['name'];
header ("Content-Type:audio/mpeg");
header ("Content-Disposition: attachment; filename=$file_name");
readfile($file_name);

?>

inimino
September 11th, 2007, 23:44
You must send the Content-Length: header as well. A Web search for "Content-Length PHP" should reveal the details.

maxelcat
September 12th, 2007, 13:09
thanks

Did know what I was looking for - that's helpful