maxelct Posted September 13, 2007 Share Posted September 13, 2007 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 More sharing options...
heckenschutze Posted September 13, 2007 Share Posted September 13, 2007 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. Link to comment https://forums.phpfreaks.com/topic/69178-solved-file-download-using-php/#findComment-347686 Share on other sites More sharing options...
phat_hip_prog Posted September 13, 2007 Share Posted September 13, 2007 header( 'Content-Length: '.filesize($fn) ); Link to comment https://forums.phpfreaks.com/topic/69178-solved-file-download-using-php/#findComment-347688 Share on other sites More sharing options...
heckenschutze Posted September 13, 2007 Share Posted September 13, 2007 Ya Link to comment https://forums.phpfreaks.com/topic/69178-solved-file-download-using-php/#findComment-347689 Share on other sites More sharing options...
maxelct Posted September 13, 2007 Author Share Posted September 13, 2007 thanks all - worked first time! Link to comment https://forums.phpfreaks.com/topic/69178-solved-file-download-using-php/#findComment-347719 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.