mattkingston Posted June 11, 2012 Share Posted June 11, 2012 Hi all. Hope you can help me. I have created a small php script that serves up a file to be downloaded, this works fine however, the estimated time left to download is unknown and i assume this is due to my script no containing the file size for web browsers to calculate the eta. Can anyone help me with this? its just a PDF of about 30MB but is important that those who download know the ETA. many thanks. Quote Link to comment https://forums.phpfreaks.com/topic/263995-php-file-server-download/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 11, 2012 Share Posted June 11, 2012 You would add a content-length header to indicate the file size - header('Content-Length: ' . filesize($your_file)); Quote Link to comment https://forums.phpfreaks.com/topic/263995-php-file-server-download/#findComment-1352921 Share on other sites More sharing options...
mattkingston Posted June 11, 2012 Author Share Posted June 11, 2012 Thanks for the info, im quite new to php so could you please explain how i enter in file size values and where i should enter it? this is my current script to serve the file (2012.pdf) whet should i add the extra line, my file size is 15.226KB, how do i translate this into the correct content length? <?php header('Content-disposition: attachment; filename=2012.pdf'); header('Content-type: application/pdf'); readfile('2012.pdf'); ?>[/blockquote> thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/263995-php-file-server-download/#findComment-1353042 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.