I need upload a file using php. I have the following code that I am using
<?php
$file = realpath('hello_world.jpg');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://api.newocr.com/v1/upload?key=*My key*');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => '@'.$file));
$result = curl_exec($ch);
echo $result;
curl_close ($ch);
?>
On executing I get the error msg-
{"status":"error","message":"File must be uploaded. www.newocr.com/.../"}
And While uploading file using cURL, I am getting error. I also tried with python but got no results.
Code mentioned below:
curl -H "Rest-User-Token: abc123" -X POST -d "Name=TheDesiredFilename" -d "FileName=filename.zip" https://<company>.telligenthosting.net/api.ashx/v2/media/383/files.json Error: {"Media":null,"Info":[],"Warnings":[],"Errors":["Only a posted file, file URL, or file upload context is valid, but not more than one."]} The documentation provides this example: curl -H "Rest-User-Token: ENCODED_TOKEN" -d "Name=name" -X POST mysite.com/.../files.xml