Hi,
As per stated in the processFields API info: "The XML file with the parameters of processing is transmitted in the request body".
In PHP, the file to be processed is transmitted in the request body as follows:
$post_array = array( "my_file"=>"@".$filePath, ); curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $post_array);
How should I include the processing parameters XML file into the request body? What should the file be named in the post_array?
Thanks, Adam
Comments
7 comments
my_file
is just a key for the array, it can really be any string. The filepath is encoded by"@".$filePath
which is literal@
prepending the file path.processFields
accepts three parameters as described in the documentation. Two parameters - task id and description - go in the URL and the third one is the XML you're asking about. Since you don't submit anything else the XML file is the only file being submitted. So you can just set$filePath
to contain the path to the XML file and use the same code as in your question:And how do I include the processing parameter xml file in the request body? Do I include it in the array as well?
I updated my answer. Questions like this one are better asked as comments to the unclear answer.
Dmitry, thanks for your answer.
I'm currently using the filePath to send the pdf file that I'm doing OCR on. How do I send that file if the array will now be filled with the processing parameter XML file?
Thanks again!
@greatrat00: First you set
filePath
to the PDF file, construct the POST parameters array and usesubmitImage
to send the pdf file. You will now have the "task id". Then you setfilePath
to the settings XML file, again construct the POST parameters array and useprocessFields
which will trigger actual processing.What if I needed to submit it as a URL from PHP with the post raw data can I do that?
You've asked that as a separate question http://forum.ocrsdk.com/questions/343/ocr-url and that question will be answered when you provide enough details to that question.
Please sign in to leave a comment.