title: Upload a Pdf file to another website using cURL
body: <p>Specifically relating to this particular thread <a href="https://stackoverflow.com/questions/27844258/upload-a-file-to-a-website-using-php">Upload a file to a website using php</a> I want to implement this using cURL on PHP.</p>
  
  <p>How do I set this up?</p>
  
  <p>Below is what I have tried.</p>
  
  <p>Note I just edited this by adding the codes I have tried.</p>
  
  <pre><code>&lt;?php
  
  
   if(isset($_POST["submit"])){
  
   $errors= array();//
   $name = $_FILES['fileToUpload']['name']; 
   $size = $_FILES['fileToUpload']['size']; 
   $type = $_FILES['fileToUpload']['type']; 
   $tmp_name = $_FILES['fileToUpload']['tmp_name']; 
   $upload_ok =1;
   $file_ext=strtolower(end(explode('.',$_FILES['fileToUpload'] 
   ['name'])));//
  
  
  
   $extensions= array("pdf","jpeg","jpg","png");
  
   $jj = file_get_contents($_FILES['fileToUpload']['tmp_name']);
   $mj = base64_encode($jj);
  
   if(in_array($file_ext,$extensions)=== false){
    $errors[]="vvvvv.";
   } 
  
   if($size &gt;= xxx){
    $errors[]='xxx;'
   }
  
   if(empty($errors)==true){
  
  
    echo  "Success &lt;/br&gt;";
  
  
    $request  = "xxxxxxxxx";
  
    $headers = array(
      "Authorization: Bearer xxxxxx",
       "Content-type =&gt; multipart/form-data",
  
  
       "Accept:application/json",
    );
  
  
  
  
  
    $data = [
  
       'voucher_data' =&gt; 'base64_encode($tmp_name)',
  
     'callback_url' =&gt; 'xxxxxxxxx'
    ];
  
  
  
  
    $curl = curl_init();
  
    curl_setopt_array($curl, array(
      CURLOPT_URL =&gt; "xxxxxxxxxx",
      CURLOPT_RETURNTRANSFER =&gt; true,
      CURLOPT_ENCODING =&gt; "",
      CURLOPT_MAXREDIRS =&gt; 10,
      CURLOPT_TIMEOUT =&gt; 30,
      CURLOPT_FOLLOWLOCATION =&gt; true,
      CURLOPT_HTTP_VERSION =&gt; CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST =&gt; "POST",
      CURLOPT_POSTFIELDS =&gt;  $data,
      CURLOPT_HTTPHEADER =&gt; $headers
    ));
  
    $response = curl_exec($curl);
  
    curl_close($curl);
  
  
    var_dump($response);
  
  
    }else{
    print_r($errors);
    }
  
  
  
  
  ?&gt;
  </code></pre>
  
  <p>I tried using curl_file_create($mj) as suggested below but on var_dump...it says bool(false)</p>