title: CURL Warning: curl_file_create() expects parameter 1 to be a valid path, string given
body: <p>I don't know why this is not working. I am trying to download a image from a URL then sent it via CURL. POST request the path with <code>var_dump</code> is working, but with CURL it doesn't work</p>
  <p>The error is</p>
  <blockquote>
  <p>Warning: curl_file_create() expects parameter 1 to be a valid path, string given</p>
  </blockquote>
  <pre><code>// define('TMP', __DIR__ . DIRECTORY_SEPARATOR . 'tmp');
  /**
   * @param $url
   * @return string
   */
  function dlImage($url) {
      $save_dir = TMP . DIRECTORY_SEPARATOR;
      $filename = basename($url);
      $save = $save_dir.$filename;
      file_put_contents($save,file_get_contents($url));
      return $save;
  }
      
  function upload( $body, $title, $type, $type_real, $subCat, $poster = null, $imdbUrl = null)
  {
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, 'xxxx');
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
      curl_setopt($ch, CURLOPT_POST, 1);
      $data = [
          'key' =&gt; 'xxxx',
          'type' =&gt; $type,
          'subtype' =&gt; $subCat,
          'type_real' =&gt; $type_real,
          'title' =&gt; $title,
          'posterUpload' =&gt;  curl_file_create(realpath(dlImage($poster)),'image/jpeg'),
          'imdbUrl' =&gt; $imdbUrl,
      ];
      curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
      $result = curl_exec($ch);
      curl_close($ch);
      var_dump($result);
  }
  // path is working fine 
  dlimage output (var_dump) : string(113) 
  
  &quot;C:\laragon\www\api\tmp\MV5BNDliY2E1MjUtNzZkOS00MzJlLTgyOGEtZDg4MTI1NzZkMTBhXkEyXkFqcGdeQXVyNjMwMzc3MjE@.jpg&quot; 
  </code></pre>