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)