title: Object of class CURLFile could not be converted to string
body: <p>How to achieve an image upload via cURL?<br/>
  I am using a sandbox api for convert pdf file to .txt file. If i use &quot;https://s3.amazonaws.com/sample.pdf&quot; path of pdf for <code>$sourceFile variable</code> then its working fine. But if i use system path &quot;test.pdf&quot; then it's not working.<br/><br/>
  I was trying to through <code>curl_file_create</code>, but it gives the following error:</p>
  <blockquote>
  <p>Recoverable fatal error: Object of class CURLFile could not be
  converted to string in line.</p>
  </blockquote>
  <p>I am using PHP Version 7.3.0</p>
  <pre><code>&lt;?php
  error_reporting(E_ALL);
  $endpoint = &quot;https://api.xxx.com/v1/jobs&quot;;
  $apiKey = &quot;GiVU******FR48H&quot;;
  $sourceFile = &quot;https://s3.amazonaws.com/sample.pdf&quot;;//new CurlFile(&quot;test.pdf&quot;);
  $targetFormat = &quot;txt&quot;;
  
  
  $postData = array(
    &quot;source_file&quot; =&gt; $sourceFile,
    &quot;target_format&quot; =&gt; $targetFormat
  );
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $endpoint);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
  curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_USERPWD, $apiKey . &quot;:&quot;);
  $body = curl_exec($ch);
  curl_close($ch);
  $response = json_decode($body, true);
  echo &quot;Response:\n---------\n&quot;;
  echo&quot;&lt;pre&gt;&quot;;
  print_r($response);
  ?&gt;
  
  Response: ---------
  Array
  (
      [id] =&gt; 8442473
      [key] =&gt; GiVU******FR48H
      [status] =&gt; initialising
      [sandbox] =&gt; 
      [created_at] =&gt; 2019-11-12T10:35:01Z
      [finished_at] =&gt; 
      [import] =&gt; Array
          (
              [id] =&gt; 671784
              [url] =&gt; https://s3.amazonaws.com/sample.pdf
              [status] =&gt; initialising
          )
  
      [target_files] =&gt; Array
          (
          )
  
      [target_format] =&gt; txt
      [credit_cost] =&gt; 0
  )
  </code></pre>
  <p>Above example give me output as fine as well. If i replace <code>amazonaws</code> from <code>system path</code> then it doesn't gives any response.</p>