title: Checking for uploaded files with file_exists
body: <p>I have a form for uploading data into my database.The form has a number of input fields ranging form text,number,textarea and file(images).</p>
  
  <p>When the form is submitted, i check if there are any images being uploaded and if so, check if the image being uploaded passes a series of checks( below maximum file size, correct extension etc), with the entire process in a try/catch block set to throw exceptions should any check fail.</p>
  
  <p>My checks are as follows:</p>
  
  <pre><code>$upload=$_FILES['Upload']['tmp_name'];
  if(isset($upload))
  {
      if(!empty($upload) &amp;&amp; is_uploaded_file($upload))
      {
          //Checks file size,extension and uploads the file
      }
      else
      {
          //throw new Exception
      }
  }
  else
  {
      //throw new Exception
  }
  </code></pre>
  
  <p>However, when using the above, isset would return true, even when no files are being uploaded.Upon some googling and looking on stack overflow, specifically <a href="https://stackoverflow.com/questions/2549055/isset-and-empty-not-passing-through-a-check-for-uploaded-files">isset and !empty not passing through a check for uploaded files</a> , where it is stated that isset will return true due to $_FILES being a superglobal, i looked around for a solution and eventually settles on file_exists() as a replacement for isset() in my code.</p>
  
  <p>My rationale for using file_exists() is that file that are uploaded(submitted) will be stored in a temp directory during the upload process, and if i check for this temp directory, i would thus be able to ascertain if a file is really uploaded.</p>
  
  <p>After replacing isset() with file_exists my code is now working fine, but i am wondering if this is the correct way to proceed, or if there are any other better alternatives.</p>
  
  <p>I look forward to any opinions and/or advice.</p>