-2

I have one cURL:

curl \
    -u <secret_api_key>: \
    -F "file=@/home/your/local/file.jpdf" \
    https://api.docparser.com/v1/document/upload/<PARSER_ID>

I am referring document: https://dev.docparser.com/#import-documents

I am not knowing how I convert -F to PHP cURL.

Sharad Soni
  • 378
  • 1
  • 5
  • 18

1 Answers1

0

You can use the following code to upload a file to Docparser:

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, "<SECRET_API_KEY>" . ":"); 
curl_setopt($ch, CURLOPT_URL, 'https://api.docparser.com/v1/document/upload/<PARSER_ID>');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file'=> '@' . realpath($file_name_with_full_path)));
$result=curl_exec($ch);
curl_close($ch);

You need to replace the values for <SECRET_API_KEY>, <PARSER_ID> and $file_name_with_full_path.

Moritz
  • 1
  • 1