title: FPDF file ---> send via CURL automatically NOT with file upload
body: <p>Hi I have managed to successfully generate a FPDF pdf file from my form submission. I have then POSTED it via CURL to an API endpoint.
  This 'file' shows inside the CRM system where supposed go but I cannot open it. 
  I believe this is not the file at all and it is not being passed stored/grabbed properly.</p>
  
  <p>Thanks</p>
  
  <p>See below code:</p>
  
  <pre><code>$noteTitle = (isset($_POST['noteTitle']) ? $_POST['noteTitle'] : null);
  $noteBody = (isset($_POST['noteBody']) ? $_POST['noteBody'] : null);
  
  require("fpdf/fpdf.php");
  $pdf = new FPDF();
  $pdf-&gt;AddPage();
  $pdf-&gt;SetFont("Arial", "B", 16);
  $pdf-&gt;Cell(0,100, "Note Title: {$noteTitle} \n", 1, 0, 'C');
  $pdf-&gt;Cell(0,100, "Note Body: {$noteBody}", 1, 0, 'C');
  $filename="testFPDF.pdf";
  $pdf-&gt;Output($filename,'F');  
  
  $headers2 = array(
      "authorization: Basic xxx",
      "content-type: multipart/form-data",
      "cache-control: no-cache",
      "postman-token: xxx"
  );   
  
  $file_name_with_full_path = 'C:/localhost/insightly-php/testFPDF.pdf';
  $timeout = 30;
  $target_url = "https://api.insight.ly/v2.1/Notes/?c_id=" . $noteID . "&amp;filename=" . $filename;
  $parameters =  array(
      'FILE_ATTACHMENTS' =&gt; '@' . $file_name_with_full_path,
      'CONTENT_TYPE' =&gt; 'application/pdf'
  );
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers2);
  curl_setopt($ch, CURLOPT_URL, $target_url);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  //curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  //curl_setopt($ch, CURLOPT_CUSTOMREQUEST,"POST");    
  //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  //curl_setopt($ch, CURLOPT_TIMEOUT, 30); 
  //curl_setopt($ch, CURLOPT_ENCODING,"");
  //curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
  //curl_setopt($ch, CURLOPT_MAXREDIRS,10);
  //curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
  //curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
  //curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
  curl_exec($ch);
  curl_close ($ch);
  </code></pre>
  
  <p>File contents are:</p>
  
  <pre><code>--------------------------xxxxxxxxxxxxxxxx
  Content-Disposition: form-data; name="FILE_ATTACHMENTS"
  
  @C:/localhost/insightly-php/testFPDF.pdf
  --------------------------xxxxxxxxxxxxxxxx--
  </code></pre>