Jump to content

Recommended Posts

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

 

$file_name= $_GET['name'];


header ("Content-Type:audio/mpeg");
header ("Content-Disposition: attachment; filename=$file_name");

readfile($file_name);

 

Link to comment
https://forums.phpfreaks.com/topic/69178-solved-file-download-using-php/
Share on other sites

You have to specify how many bytes follow, ie, "Content-Length:" (google it)

 

And put the  length of the file (in bytes), since the data is piped in a stream the browser has no idea when it will stop or how many bytes follow.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.