I use sample code for PHP how ever after upload image to server. Anyone can help?

$url = 'http://cloud.ocrsdk.com/processImage?language=english&exportFormat=rtf';

// Send HTTP POST request and ret xml response
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt ($curlHandle, CURLOPT_CONNECTTIMEOUT, 20 );
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlHandle, CURLOPT_USERPWD, "$applicationId:$password");
curl_setopt($curlHandle, CURLOPT_POST, 1);
curl_setopt($curlHandle, CURLOPT_USERAGENT, "PHP Cloud OCR SDK Sample");
$post_array = array(
    "my_file"=>"@".$filePath,
);
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $post_array); 
$response = curl_exec($curlHandle);

$response is empty.

asked 23 May '13, 21:40

mynigo's gravatar image

mynigo
1

edited 24 May '13, 19:05

Dmitry%20Me's gravatar image

Dmitry Me ♦♦
2387


This code snippet is from PHP sample on Github:

$response = curl_exec($curlHandle);
if($response == FALSE) {
  $errorText = curl_error($curlHandle);
  curl_close($curlHandle);
  die($errorText);
}

Note the if($response == FALSE) { check - in case of error $response will be set to FALSE and if you echo it you indeed see empty output.

So the bottom line is you have to handle this case in a manner similar to how it is handled in the sample - anticipate FALSE and call curl_error() to obtain error details.

link

answered 24 May '13, 19:12

Dmitry%20Me's gravatar image

Dmitry Me ♦♦
2387

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×5
×3

Asked: 23 May '13, 21:40

Seen: 895 times

Last updated: 24 May '13, 19:12

© 2016 ABBYY. All rights Reserved. www.ABBYY.com | Privacy Policy | Legal