php curl, download size limit

Discussion in 'PHP' started by phpmania, Apr 26, 2009.

  1. #1
    Hi all
    How I can get the page by php curl only first 10 character or only first 10 kb of page I don’t what download all of page.
    Dose any one have idea
    Thanks
     
    phpmania, Apr 26, 2009 IP
  2. tguillea

    tguillea Active Member

    Messages:
    229
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #2
    Not sure if this will work but if you can access remote files you could use the following

    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "remote_filename.txt");
    //you might need to uncomment below?
    //curl_setopt($ch, CURLOPT_FILE, fopen("destination/to_save/filename.txt"));
    
    //execute the curl by opening the file
    $handle = fopen(curl_exec($ch),"w+");
    //save the file
    $file_string = fread($handle,10);
    // CLOSE CURL
    curl_close ($ch);
    fclose($handle);
    
    PHP:
    I just kind of threw this together and have no idea if it will work. It will definitely need some modification to work.

    Good luck!
     
    tguillea, Apr 26, 2009 IP
  3. xenon2010

    xenon2010 Peon

    Messages:
    237
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    does it work?
     
    xenon2010, Dec 7, 2009 IP
  4. xenon2010

    xenon2010 Peon

    Messages:
    237
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    nvm
    just used
    curl_setopt($ch, CURLOPT_RANGE,"1-2000"); //where 1-2000 range of downloaded bytes
     
    xenon2010, Dec 7, 2009 IP