View Full Version : resume downloading link

02-26-2012, 06:56 AM
i have special case of resuming download, the file is not on server. the file is located at remote server, let's say

and i'm using ranged curl to fetch the file and echo it on user's browser

header('Cache-control: private');
header('Content-Type: application/octet-stream');
header('Content-Length: '.$filesize);
header('Content-Disposition: filename=name');

$end_range = $filesize;
while($start_range <= $end_range) {
if(($start_range + 9999999) > $end_range) $range = $start_range.'-'.$end_range;
else $range = $start_range.'-'.($start_range + 9999999);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20061204 Firefox/');
curl_setopt($ch, CURLOPT_RANGE,$range);
$start_range +=10000000;

what should i change in code so that the user will be able to resume the download??

02-26-2012, 11:05 AM
Download Flashget and install it.

Then download a large file (eg a linux iso) and pause and resume it a few times. You'll soon see the commands that you need to use and look for :thumbsup:

02-26-2012, 09:55 PM
i did that. i see some headers like keep-alive etc but how can i implement it in php, can u show some help code wise please

02-26-2012, 10:13 PM
can u show some help code wise please

Erm no. I offered to sort this for you a long time ago and you declined saying you could do it yourself. Instead I continued to provide general advice to you on the basis that I would not write actual code. I will continue to give you advice (as above) but I'm afraid I will not be writing code for this for free as its not the easiest of tasks and you previously claimed it was only a 5-10 minute job (yet months later you're still trying to get it working and it took me 4-5 hours including debugging etc).

Flashget will provide you with the answers you need. You just need to carefully watch what it is doing and be careful to monitor the actual bytes you receive for the file (eg one extra bye or one less byte than the file should be and the file is corrupt). For that purpose, check each test file download for a matching MD5 hash.

02-26-2012, 10:49 PM
no got it wrong, i was talking about ranged curl that took me only 5-10 mins

this is resume downloaded, you offered to write it but i never asked or started a thread about it

02-26-2012, 11:34 PM
You need to look at the $_SERVER array for the ranges.

02-27-2012, 07:18 PM
hello, i know it theoretically, i know have to look for $_SERVER ranges and set curl ranges and partial content header but can you show some help code wise please

02-29-2012, 10:13 AM
anyhow, i fixed it with 6 lines of code. thanks for your help but i would prefer if you don't bother yourself and post some 2cents posts which you call help!!

02-29-2012, 11:24 AM
i would prefer if you don't bother yourself and post some 2cents posts which you call help!!

With your continual reassurance that you could manage it I knew you'd be ok. Besides, I offered to supply you code previously and you refused it. Why do you think I should now supply you with code? - Your last thread was full of insults towards me yet I still gave you tips in this thread. Now you've decided to insult me again I won't even bother doing that next time.

No-one here is under any obligation to help you. No-one else has helped you. You should be grateful that I did.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum