Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Sep 2010
    Posts
    65
    Thanks
    4
    Thanked 0 Times in 0 Posts

    resume downloading link

    Hello,
    i have special case of resuming download, the file is not on server. the file is located at remote server, let's say
    Code:
    http://server/file.zip
    and i'm using ranged curl to fetch the file and echo it on user's browser

    PHP Code:
        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($chCURLOPT_URL$url2);
                
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
                
    curl_setopt($chCURLOPT_USERAGENT'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
                
    curl_setopt($chCURLOPT_RANGE,$range);
                
    curl_exec($ch);
                
    curl_close($ch);
                
    $start_range +=10000000;
                
    flush();
            } 

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

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,281
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5
    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
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    New Coder
    Join Date
    Sep 2010
    Posts
    65
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,281
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5
    Quote Originally Posted by TheCracker View Post
    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.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #5
    New Coder
    Join Date
    Sep 2010
    Posts
    65
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,281
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5
    You need to look at the $_SERVER array for the ranges.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #7
    New Coder
    Join Date
    Sep 2010
    Posts
    65
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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

  • #8
    New Coder
    Join Date
    Sep 2010
    Posts
    65
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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!!

  • #9
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,281
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5
    Quote Originally Posted by TheCracker View Post
    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.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •