title: php curl post call for uploading image with other attributes
body: <p>I am using a basic PHP curl to post data to <a href="http://www.inaturalist.org/pages/api+reference#post-observation_photos" rel="nofollow">iNaturalist API call</a> but I am getting internal server error.</p>
  
  <p>My HTML code is: </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;body&gt;
  
      &lt;form action="imageuploaddir.php" method="post" enctype="multipart/form-data"&gt;
          Select image to upload:
          &lt;input type="file" name="fileToUpload" id="fileToUpload"&gt;
          &lt;input type="submit" value="Upload Image" name="submit"&gt;
  
      &lt;/form&gt;
  
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>and my imageuploaddir.php code is</p>
  
  <pre><code> &lt;?php
  $authorization = "Authorization: Bearer ###somekey;
  
  $file=$_FILES["fileToUpload"];
  
  $postfields = array('file' =&gt;'@'.$file,'observation_photo[observation_id]'=&gt; 4230809);
  var_dump($postfields);
  $ch =curl_init();
  curl_setopt($ch,CURLOPT_URL,"http://www.inaturalist.org/observation_photos");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_HEADER,FALSE);
  curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
  curl_setopt($ch, CURLOPT_VERBOSE,1);
  curl_setopt($ch, CURLOPT_POST,TRUE);
  curl_setopt($ch, CURLOPT_POSTFIELDS,$postfields);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Content-Type: multipart/form-data",
    $authorization
  ));
  $response = curl_exec($ch);
  $err = curl_error($ch);
  
  curl_close($ch);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
  
  ?&gt;
  
  
  
  
   $postfields = array('file' =&gt;'@'.$file,'observation_photo[observation_id]'=&gt; 4230809);
  </code></pre>
  
  <p>When I give a post in this format I get an error:</p>
  
  <blockquote>
    <p>Notice: Array to string conversion </p>
  </blockquote>