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 1 of 1
  1. #1
    New Coder
    Join Date
    Oct 2009
    Posts
    71
    Thanks
    16
    Thanked 0 Times in 0 Posts

    curl help for img

    I hope i can get help here, i am not good in curl and trying to write a function which will upload an image to a free imagehost, Currently what this script does is it will go to the site and try to post the image but it always get reply:

    "Upload is disabled during short maintenance work (ETA 10 minutes). Brb!".

    but if i add image from my computer without using this script it is working normally, i need to run this script stand alone, so when i open the file it will run the script, here is the code i am trying to use,
    PHP Code:
    <?php
    set_time_limit
    (0);
    session_start();


    $agent"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14";

    $reffer"http://www.pixhost.org/classic-upload/";
    $cookie_file_path 'cookie.txt'
    $fp fopen($cookie_file_path,'wb');   
    if(!
    $fp)
    echo 
    'error opning cookie file';
    fclose($fp);



    $ch curl_init();
    curl_setopt($chCURLOPT_URL,"http://www.pixhost.org/classic-upload/");
    curl_setopt($chCURLOPT_USERAGENT$agent);
    curl_setopt($chCURLOPT_COOKIEFILE$cookie_file_path);
    curl_setopt($chCURLOPT_COOKIEJAR$cookie_file_path);
    curl_setopt($chCURLOPT_REFERER"");
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
    curl_setopt($chCURLOPT_SSL_VERIFYHOST0);
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    $html curl_exec($ch);


    $ch curl_init();
    curl_setopt($chCURLOPT_URL'http://www.pixhost.org:8080/classic-upload/"');
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
    curl_setopt($chCURLOPT_SSL_VERIFYHOST0);
    curl_setopt($chCURLOPT_RETURNTRANSFER,1);
    curl_setopt($chCURLOPT_REFERER,$reffer);
    curl_setopt($chCURLOPT_POST1);
    //curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    // curl_setopt($ch, CURLOPT_COOKIESESSION, true);
    curl_setopt($chCURLOPT_USERAGENT$agent);        
    curl_setopt($chCURLOPT_COOKIEFILE$cookie_file_path);
    curl_setopt($chCURLOPT_COOKIEJAR$cookie_file_path);
    curl_setopt($chCURLOPT_FOLLOWLOCATION,1);
    $postRes curl_exec($ch);



    $data = array('content_type' => '1''image[]' => '@image.gif');
    $ch curl_init();
    curl_setopt($chCURLOPT_URL'http://www.pixhost.org:8080/java.php"');
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
    curl_setopt($chCURLOPT_SSL_VERIFYHOST0);
    curl_setopt($chCURLOPT_RETURNTRANSFER,1);
    curl_setopt($chCURLOPT_REFERER,'http://www.pixhost.org:8080/classic-upload/');
    curl_setopt($chCURLOPT_POST1);
    curl_setopt($chCURLOPT_POSTFIELDS$data);
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    curl_setopt($chCURLOPT_COOKIESESSIONtrue);
    curl_setopt($chCURLOPT_USERAGENT$agent);        
    curl_setopt($chCURLOPT_COOKIEFILE$cookie_file_path);
    curl_setopt($chCURLOPT_COOKIEJAR$cookie_file_path);
    curl_setopt($chCURLOPT_FOLLOWLOCATION,1);
    $postResult curl_exec($ch);

    if (
    curl_errno($ch)) {
    print 
    curl_error($ch);
    }
    curl_close($ch);
    print 
    $postResult ;

    ?>
    i have an image named "image.gif" in same folder when i run this file, please if you can run the script once you will see what i mean, Please can some one help me sort this i really appreciate and hope this community can help me,

    Thanks
    Last edited by Dshah; 03-04-2010 at 09:23 AM.


 

Posting Permissions

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