Other Sample Code

If you are using cURL in PHP, you can refer to the code example below:

<?php 
 // construct post data
 $fileName = 'esempio.jpg';
 $filePath = dirname(__FILE__).DIRECTORY_SEPARATOR.$fileName;
 $args['file'] = new CurlFile($filePath, 'image/jpg', $fileName);
 
 // upload file to DDC Rest
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, 'https://cloud.dynamsoft.com/rest/ocr/v1/file?method=upload&ondup=overwrite');
 curl_setopt($ch, CURLOPT_HTTPHEADER, array('x-api-key:kEltMHPKwtVzpkcSDIBHU/PtswciLz************', 'Content-Type: multipart/form-data')); 
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // On dev server only
 echo curl_exec($ch);
 curl_close ($ch);
?>
Is this page helpful?

Leave a Reply

Your email address will not be published.