PHP: CurlFile upload with remote URL
<p>From past few days I have been searching on how to upload file in PHP >=5.5 with Curl. Finally I found the new <a href="http://php.net/manual/en/class.curlfile.php" rel="nofollow">CurlFile</a> method but cant get it work with remote URLs. Here is the code i am using:</p>

<pre><code>        $access_token = 'MY_API_ACCESS_TOKEN';
        $fields = array(
            "name" =&gt; $name,
            "parent" =&gt; array(
                "id" =&gt; $folder_id
            )
        );
        $another = array(
            'attributes' =&gt; json_encode($fields),
            'file' =&gt; new CurlFile($remoteUrl)
        );
        $header = array (
            "Authorization: Bearer $access_token",
            "Content-Type: multipart/form-data"
        );
        $options = array(
            CURLOPT_URL =&gt; $UPLOAD_URL,
            CURLOPT_POST =&gt; true,
            CURLOPT_POSTFIELDS =&gt; $another,
            CURLOPT_HTTPHEADER =&gt; $header,
            CURLOPT_RETURNTRANSFER =&gt; true,
            CURLOPT_SSL_VERIFYPEER =&gt; false
        );
        $ch = curl_init();
        curl_setopt_array($ch, $options);
        $response = curl_exec($ch);
        curl_close($ch);
</code></pre>

<p>When replacing the <code>$remoteUrl</code> with local file path everything works fine.</p>

<p><strong>Q] Is the remote upload possible with CurlFile? If yes what am I doing wrong?</strong></p>