title: CURL - php vs command line bash
body: <p>From bash terminal, I successfully executed the following command.</p>
  
  <pre><code>curl -v -L -F file='@/var/www/dev/public_html/sixties.mov' -F title='my video' -F description='this is a video' -F language='eng' -F license='a2be14e1-37d9-11dd-ae16-0800200c9a66' -F country='US' http://johnuser:johnpass@website.com/api/media
  </code></pre>
  
  <p>Now I want to create a PHP script that uses the phpcurl library to execute an equivalent command.  My code below is shown, but it's not working.  The <code>http://johnuser:johnpass@website.com/api/media</code> server is giving me a generic error message.  I'm pretty sure I'm making a mistake by not passing the right parameters or setting the right flags in my php code.  Can anyone tell me what's wrong?</p>
  
  <pre><code>$url = 'http://johnuser:johnpass@website.com/api/media';
  
  $fields = array();
  $fields['file'] = '@/var/www/dev/public_html/sixties.mov';
  $fields['title'] = 'my video';
  $fields['description'] = 'this is a test';
  $fields['language'] = 'eng';
  $fields['country'] = 'US';
  $fields['license'] = 'a2be14e1-37d9-11dd-ae16-0800200c9a66';
  
  foreach($fields as $key=&gt;$value) { $fields_string .= $key.'='.$value.'&amp;'; }
  rtrim($fields_string,'&amp;');
  
  $ch = curl_init();
  
  //set the url, number of POST vars, POST data
  curl_setopt($ch,CURLOPT_URL,$url);
  curl_setopt($ch,CURLOPT_POST,count($fields));
  curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
  
  //execute post
  $result = curl_exec($ch);
  
  //close connection
  curl_close($ch);
  print_r($result);
  </code></pre>
  
  <p>The error message I got is <code>{"status":{"message":"typeMismatch ","error":true,"code":500}}</code></p>