Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Uploading an image using curl to remote location

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 104
    Comment on it

    When you are trying to upload a file . file get always uploaded using post. So you need to place @ before the file name which you want to send as a post. Using @before the file path in order to make sure that CURL sends the file in the form of a multipart/form-data post . This can be because api may not return anything while successful uploading.

     $ch = curl_init("http://imagezilla.net/api.php?apikey=''&testmode=1");
     $post = array(
        "file"=>"@C:\penguins.jpg",
    );
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $output = curl_exec($ch);       
     curl_close($ch);
     echo $output;
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: