By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,120 Members | 1,799 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,120 IT Pros & Developers. It's quick & easy.

Need "Resume Support" in forced downloding of media file

P: 8
I am using the following PHP code to force the internet browser to download a media file(e.g, .mp3, .wma), But in this code, there is no resume support in downloading these files.
i dont know PHP, i am very much thankful to the person who gave me this code.
Kindly tell me, that what changings are to be needed to enable resume support in downloading.
Thankyou.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. if((array_key_exists('file', $_GET)) && ($fp = @fopen($_GET['file'], 'rb')) && (pathinfo($_GET['file'], PATHINFO_EXTENSION) != 'php'))
  4. {
  5.     header('Content-Disposition: attachment; filename="' . basename($_REQUEST['file']) . '";' );
  6.     header('Content-Transfer-Encoding: binary');
  7.     header('Content-Length: ' . filesize($_GET['file']));
  8.     fpassthru($fp);
  9. }
  10. else
  11. {
  12. ?><html>
  13.     <head>
  14.         <title>404 - File not found</title>
  15.     </head>
  16.     <body>
  17.         <div style="font-size:36px;">File not found</div>
  18.         <div style="font-size:12px;">The file you requested ('<?php echo $_GET['file'] ?>') could not be found.</div>
  19.     </body>
  20. </html><?php
  21. }
  22. ?>
  23.  
Sep 19 '07 #1
Share this Question
Share on Google+
4 Replies


Atli
Expert 5K+
P: 5,058
Hi.

What do you mean by "resume"?
Are you trying to continue a half finished download?
Sep 20 '07 #2

P: 8
Hi.

What do you mean by "resume"?
Are you trying to continue a half finished download?


Yes you are right,
i am using download accelerator to do download my files but it gives error message in start of downloading that "resume not supported". means if user lost his connection than it is not possible to start/resume download from the broken state. Means that if a user is downloading 3 mb file, and after 2 mb of download if user lost internet connection, or due to power failure, than the user will lost 2 mb, and user must start downlaoding from the beginning.
Actualy, when i use download.php for forced download than there is no resume supprt, but when i use normal downloading (means to right click on link and select "save target as...") than there is a resume support, but by using download.php (above given code) there is no resume support.
Kindly tell me is there any problem in the above code, or what should i do?????
Thankyou
Sep 20 '07 #3

Atli
Expert 5K+
P: 5,058
I see.

The reason why your download accelerator can't resume the download is because there is no actuall file to download.
Your download.php is reading the file from the very beginning every time the file is requested.

Without actually knowing how the acceleration program works, I would assume that it can somehow request a portion of the file from the server, which your PHP code is unable to understand.

If you are able to find out how your application is able to request a portion of a file, you may be able to re-write your PHP script to understand it and send only the part requested.
Sep 21 '07 #4

P: 8
I see.

The reason why your download accelerator can't resume the download is because there is no actuall file to download.
Your download.php is reading the file from the very beginning every time the file is requested.

Without actually knowing how the acceleration program works, I would assume that it can somehow request a portion of the file from the server, which your PHP code is unable to understand.

If you are able to find out how your application is able to request a portion of a file, you may be able to re-write your PHP script to understand it and send only the part requested.

Thanks,
i dont have any knowledge about it, will you please do it for me.
Thankyou and waiting for your reply.
Sep 22 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.