title: Attaching $fields to $_FILES
body: <p>If I have the following associative array:</p>
  
  <pre><code>$fields = [                                 //store empty fields
      'name' =&gt; $_POST['name'],
      'email' =&gt; $_POST['email'],     
      'phone' =&gt; $_POST['phone'],
      'location' =&gt; $_POST['location'],
      'proposal' =&gt; $_POST['proposal'] //--------------&gt; proposal = attachment file
  ];
  </code></pre>
  
  <p>How do I use them for <code>$_FILES["attachment"]["name"]</code> ?</p>
  
  <p>My plan is to check whether the proposal is pdf, docx, or .doc</p>
  
  <p>here is what I did so far:</p>
  
  <pre><code>        if(!empty($_FILES[$fields['proposal']]['name']) ){
              //variables
              $fileName = $_FILES[$fields['proposal']]['name'];
              $tempName = $_FILES[$fields['proposal']]['tmp_name'];
              $fileType = $_FILES[$fields['proposal']]['type'];
  
              //get the extension of the file
              $base = basename($fileName);
              $extension = substr($base, strlen($base)-4, strlen($base));
  
              //only these file types will be allowed
              $allowedExtension = array(".doc", ".pdf", "docx");
  
              //check that this file type is allowed
              if (in_array($extension, $allowedExtension)) {
  
  
              }else {
              $errors['proposal'] = 'You can only upload pdf files';                  
  
              } 
          }
  </code></pre>