title: How can I use cURL to post form data in php?
body: <p>I have the following command, which uses the --form/--F option, which I know to be working: </p>
  
  <pre><code>curl  --form "file=@/home/USERNAME/import.csv" https://apiprovider.com/api/v0/imports\?token\=[KEY]
  </code></pre>
  
  <p>I need to run this command via php, but I'm having trouble, presumably with the form file data. I tried the following, however echoing or var_dumping the result seems to show nothing, just a blank page or a blank string. </p>
  
  <pre><code>&lt;?php 
  $target_url = 'https://apiprovider.com/api/v0/imports?token=[KEY]'
  $file_name_with_full_path ='/home/USERNAME/import.csv';
  $post = array('file'=&gt;'@'.$file_name_with_full_path);
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$target_url);
  curl_setopt($ch, CURLOPT_POST,1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_VERBOSE,true);
  $result=curl_exec ($ch);
  curl_close ($ch);
  var_dump($result);?&gt;
  </code></pre>
  
  <p>How can I get this command working in PHP?</p>