title: Upload image using curl
body: <pre><code>$ curl --request POST \
          --url 'UPLOAD_URL' \
          --upload-file 'PATH_TO_FILE' \
          --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'
  </code></pre>
  
  <p>How to convert this curl code in php</p>
  
  <p>I am using this way but its giving me error...</p>
  
  <pre><code>$file_name =
   "http://stview.agencia.co.jp:8080/STVIEW/main/google-api-php/test/image/1.jpg";
   // $file_name = 
   "/var/www/stview/public_html/STVIEW/main/google-api-php/test/image/1.jpg";
  
   if(function_exists('curl_file_create')) {
     $cFile = curl_file_create($file_name); 
  
   } else {
     $cFile = '@' . realpath($file_name); 
  
   }
  
   $post = array('extra_info' =&gt; '123456','file_contents'=&gt; $cFile);
   $data = array('name' =&gt; 'Foo', 'file' =&gt;
   '@/var/www/stview/public_html/STVIEW/main/google-api-php/test/image/1.jpg');
  
  
   $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,
   'https://streetviewpublish.googleapis.com/media/user/117051626264904472027/photo/2668839193146023612');
  
   curl_setopt($ch, CURLOPT_HTTPHEADER, array(
         "authorization: Bearer ya29.GltZBMH9XSn56qs5PHsYpjC-WfFeff9dpnDXr1I-xtN0L8wNRQWVRZsgzEShAFij4N7u7uDXPW4UA5yZ9qqy3dgWjxawRHlhQ0OgwDOJetyj9cSwEah5HZ6NnzJQ",
         "content-type: application/json"   ));
  
   curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
   // curl_setopt($ch, CURLOPT_UPLOAD, true);
   // curl_setopt($ch, CURLOPT_POST, true); // enable posting
   // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLINFO_HEADER_OUT, true);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  
  
   $info = curl_getinfo($ch);
   $result=curl_exec ($ch);
   $err = curl_error($ch);
  
   echo "info-" . print_r($info) . "&lt;br&gt;\n"; echo "result-" . $result .
   "&lt;br&gt;\n"; echo "error-" . $err . "&lt;br&gt;\n"; var_dump($result) ;
   print_r($result);
  </code></pre>
  
  <p>Please let me know where I am doing wrong.</p>
  
  <p>My output is 
  <em>No file found in the request.</em></p>