title: Warning: mime_content_type(): Empty filename or path
body: <p>Folks,</p>
  
  <p>I created a form where you upload your image file and video file.
  Form needs to check if right file formats getting submitted or not and whether the file sizes are within the limits or not.
  That is all.</p>
  
  <p>I get this error:
  " Warning: mime_content_type(): Empty filename or path in C:\xampp\htdocs\test\02-04-2020\upload_test.php on line 100"</p>
  
  <p>Line 100 code is this:</p>
  
  <pre><code>    if(!in_array(mime_content_type($video_file_tmp),$video_mime_type))
  </code></pre>
  
  <p>NOTE: I checking against tmp file above. Should I be doing that or checking against actual file name ?
  Talking about these:</p>
  
  <pre><code>$video_file_name = $_FILES["id_verification_video_file"]["name"]; 
  $video_file_tmp = $_FILES["id_verification_video_file"]["tmp_name"];
  </code></pre>
  
  <p>Context</p>
  
  <pre><code>    if(!in_array(mime_content_type($video_file_tmp),$video_mime_type)) 
      { 
          $error_msg['video_error'] =  '&lt;p class="text-danger"&gt;ERROR STATEMENT 3b: Invalid File! Only MP4, WAV, OGG, FLV, WMV and AVI video files are allowed!'; 
          $error = 1; 
      } 
  </code></pre>
  
  <p>And I get these custom errors triggered:</p>
  
  <p><strong>ERROR STATEMENT 2a: Invalid File! Only JPG, JPEG, PNG and GIF image files are allowed!</strong> </p>
  
  <p><strong>ERROR STATEMENT 3b: Invalid File! Only MP4, WAV, OGG, FLV, WMV and AVI video files are allowed!</strong></p>
  
  <p>They are related to these lines:</p>
  
  <p>1.</p>
  
  <pre><code>    if(!in_array(pathinfo($img_file_tmp,     PATHINFO_EXTENSION),$img_allowed_ext)) 
          { 
              $error_msg['img_error']= '&lt;p class="text-    danger"&gt;ERROR STATEMENT 2a: Invalid File! Only JPG, JPEG, PNG and     GIF image files are allowed!'; 
              $error = 1; 
          } 
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>           if(!in_array(mime_content_type($video_file_tmp),$video_mime_type)) 
      { 
          $error_msg['video_error'] =  '&lt;p class="text-danger"&gt;ERROR STATEMENT 3b: Invalid File! Only MP4, WAV, OGG, FLV, WMV and AVI video files are allowed!'; 
          $error = 1; 
      }  
  </code></pre>
  
  <p>NOTE AGAIN: I checking against tmp file above. Should I be doing that or checking against actual file name ?</p>
  
  <p>If I can findout why I am getting that first WARNING ERROR then the other 2 custom errors would disappear. What does that WARNING mean and why am I getting it ?
  I was checking valid file extensions against the tmp files. Watch-out for this on my code.</p>
  
  <p>Full Code</p>
  
  <pre><code>    &lt;?php 
  
      $error_msg =  array(); 
      $success_msg =  array(); 
  
      $img_allowed_ext = array('gif','jpeg','jpg','png'); 
      $video_allowed_ext =           array('mp4','wav','wmv','avi','flv','ogg');  
  
      $img_mime_type =  array('image/gif','image/jpeg','image        /jpg','image/png'); 
      $video_mime_type =  array('video/mp4','video/wav','video        /wmv','video/avi','video/flv','video/ogg'); 
  
  
      if($_SERVER["REQUEST_METHOD"] == "POST") 
      { 
  $error = 0 ; 
  //var_dump($_Files); //For debugging. 
  
  //Check whether the file was uploaded or not without any errors. 
  if(!isset($_FILES["id_verification_video_file"]) || !isset($_FILES['id_verification_img_file'])) 
  { 
      $error_msg['all_fields'] =  '&lt;p class="text-danger"&gt;ERROR STATEMENT 1: Select all fields that have asterisks besides them!&lt;/p&gt;'; 
      $error = 1;             
  } 
  else 
  { 
      //Image Files 
      $img_file_name = $_FILES["id_verification_img_file"]["name"]; 
      $img_file_tmp = $_FILES["id_verification_img_file"]["tmp_name"];
      $img_file_type = $_FILES["id_verification_img_file"]["type"]; 
      $img_file_size = $_FILES["id_verification_img_file"]["size"]; 
      $img_file_error = $_FILES['id_verification_img_file']['error']; 
  
      $img_file_ext = pathinfo($img_file_name, PATHINFO_EXTENSION); 
      //$img_file_ext = pathinfo($img_file_tmp, PATHINFO_EXTENSION); //WRONGLY SAVES FILE NAMES WITH .tmp!
  
      //Video Files 
      $video_file_name = $_FILES["id_verification_video_file"]["name"]; 
      $video_file_tmp = $_FILES["id_verification_video_file"]["tmp_name"]; 
      $video_file_type = $_FILES["id_verification_video_file"]["type"]; 
      $video_file_size = $_FILES["id_verification_video_file"]["size"]; 
      $video_file_error = $_FILES['id_verification_video_file']['error']; 
  
      $video_file_ext = pathinfo($video_file_name, PATHINFO_EXTENSION); 
      //$video_file_ext = pathinfo($video_file_tmp, PATHINFO_EXTENSION); //WRONGLY SAVES FILE NAMES WITH .tmp!
  
      //Checking File Type.           
      //Checking File Type using pathinfo_extension() Function. 
  
      /*
      if(!in_array(pathinfo($img_file_name, PATHINFO_EXTENSION),$img_allowed_ext)) 
      { 
          $error_msg['img_error']= '&lt;p class="text-danger"&gt;ERROR STATEMENT 2a: Invalid File! Only JPG, JPEG, PNG and GIF image files are allowed!'; 
          $error = 1; 
      } 
      */          
      //The error statement gets echoed even after selecting right type of file! 
      if(!in_array(pathinfo($img_file_tmp, PATHINFO_EXTENSION),$img_allowed_ext)) 
      { 
          $error_msg['img_error']= '&lt;p class="text-danger"&gt;ERROR STATEMENT 2a: Invalid File! Only JPG, JPEG, PNG and GIF image files are allowed!'; 
          $error = 1; 
      }           
  
      /*
      if(!in_array(pathinfo($video_file_name, PATHINFO_EXTENSION),$video_allowed_ext)) 
      { 
          $error_msg['video_error'] =  '&lt;p class="text-danger"&gt;ERROR STATEMENT 2b: Invalid File! Only MP4, WAV, OGG, FLV, WMV and AVI video files are allowed!'; 
          $error = 1; 
      }           
      */
      //The error statement gets echoed even after selecting right type of file! 
      if(!in_array(pathinfo($video_file_tmp, PATHINFO_EXTENSION),$video_allowed_ext)) 
      { 
          $error_msg['video_error'] =  '&lt;p class="text-danger"&gt;ERROR STATEMENT 2b: Invalid File! Only MP4, WAV, OGG, FLV, WMV and AVI video files are allowed!'; 
          $error = 1; 
      }           
  
  
      //Checking File Type. 
      //Checking Mime Type using mime_content_type() Function. 
  
      /*
      if(!in_array(mime_content_type($img_file_name),$img_mime_type)) 
      { 
          $error_msg['img_error']= '&lt;p class="text-danger"&gt;ERROR STATEMENT 3a: Invalid File! Only JPG, JPEG, PNG and GIF image files are allowed!'; 
          $error = 1; 
      } 
      */
      if(!in_array(mime_content_type($img_file_tmp),$img_mime_type)) 
      { 
          $error_msg['img_error']= '&lt;p class="text-danger"&gt;ERROR STATEMENT 3a: Invalid File! Only JPG, JPEG, PNG and GIF image files are allowed!'; 
          $error = 1; 
      } 
  
      /*
      if(!in_array(mime_content_type($video_file_name),$video_mime_type)) 
      { 
          $error_msg['video_error'] =  '&lt;p class="text-danger"&gt;ERROR STATEMENT 3b: Invalid File! Only MP4, WAV, OGG, FLV, WMV and AVI video files are allowed!'; 
          $error = 1; 
      } 
      */          
      if(!in_array(mime_content_type($video_file_tmp),$video_mime_type)) 
      { 
          $error_msg['video_error'] =  '&lt;p class="text-danger"&gt;ERROR STATEMENT 3b: Invalid File! Only MP4, WAV, OGG, FLV, WMV and AVI video files are allowed!'; 
          $error = 1; 
      } 
  
      //Checking File Sizes using filesize() function. 
      //5MB Image Size Allowed. 
      if(filesize($img_file_tmp) &gt; 5000000) 
      { 
          $error_msg['img_file_size_err'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 4a: File Size is greater than 5MB. File Size should not exceed the 100MB limit!'; 
          $error = 1; 
      } 
      //10MB Video Size Allowed.          
      if(filesize($video_file_tmp) &gt; 10000000) 
      { 
          $error_msg['video_file_size_err'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 4b: File Size is greater than 10MB. File Size should not exceed the 100MB limit!';  
          $error = 1; 
      }           
  
      //Checking for NO errors to proceed with the script flow. 
      if($error == 0)
      { 
          $user = $user; //Account Username here. 
          //$db_user = 'followingbrowser_user'; //Database username here. Has to be in quotes. 
          $db_user = 'root'; //Database username here. Has to be in quotes. 
          //Feed Id Verification Video &amp; Image File Upload Directory path. 
          $default_directory_path = 'uploads/id_verifications'; //Permanent Storage Directory Path. 
          $default_directory_path_and_user_dir = "$default_directory_path"."/".$user; //Permanent Storage Directory Path for $user Folder. 
  
          //Create $user Folder in Permanent Storage Directory Path: 'uploads/videos/id_verifications' Folder.                
          if(!is_dir($default_directory_path_and_user_dir)) 
          {               
              //$db_user = 'followingbrowser_user'; //Has to be in quotes. 
              $db_user = 'root'; //Has to be in quotes. 
              $mode = 0755; 
              mkdir($default_directory_path_and_user_dir,$mode,TRUE); //This line is working and is correct even without quoting "$mode". Requinix sugegsted to quote "$mode". 
          } 
  
         //Making Directories of every Files Types for Respective User.               
          $user_img_directory = "$default_directory_path_and_user_dir"."/"."imgs"; 
          $user_video_directory = "$default_directory_path_and_user_dir"."/"."videos"; 
  
          if(!is_dir($user_img_directory)) 
          { 
              //$db_user = 'followingbrowser_user'; //Has to be in quotes. 
              $db_user = 'root'; //Has to be in quotes. 
              $mode = 0755; 
              mkdir($user_img_directory,$mode,TRUE); //This line is correct and working even without quoting $mode.
          } 
  
          if(!is_dir($user_video_directory)) 
          { 
              //$db_user = 'followingbrowser_user'; //Has to be in quotes. 
              $db_user = 'root'; //Has to be in quotes. 
              $mode = 0755; 
              mkdir($user_video_directory,$mode,TRUE); //This line is correct and working even without quoting $mode. 
          }               
  
          //User Files Directories. 
          $default_directory_path = 'uploads/id_verifications'; //Permanent Storage Directory Path. 
          $default_directory_path_and_user_dir = "$default_directory_path"."/"."$user"; //Permanent Storage Directory Path for $user Folder. 
          $user_img_directory = "$default_directory_path_and_user_dir"."/"."img"; 
          $user_video_directory = "$default_directory_path_and_user_dir"."/"."videos"; 
          $user_id_img_file = "$user_img_directory"."/"."$img_file_name"."$img_file_ext"; 
          $user_id_video_file = "$user_video_directory"."/"."$video_file_name"."$video_file_ext"; 
  
          //Uploading the Files. 
          $upload_err =  0; 
  
          //Uploading Image File 
          if(file_exists("$user_img_directory/$user.gif")) 
          { 
              $error_msg['upload_img_error'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 5d: You have already uploaded an Image File to verify your ID! No need to upload to get verified again! If you uploaded the wrong file then you need to delete this account and open a new one!&lt;/p&gt;'; 
              $upload_err = 1; 
          } 
          elseif(file_exists("$user_img_directory/$user.jpeg")) 
          { 
              $error_msg['upload_img_error'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 5a: You have already uploaded an Image File to verify your ID! No need to upload to get verified again! If you uploaded the wrong file then you need to delete this account and open a new one!&lt;/p&gt;'; 
              $upload_err = 1; 
          } 
          elseif(file_exists("$user_img_directory/$user.jpg")) 
          { 
              $error_msg['upload_img_error'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 5b: You have already uploaded an Image File to verify your ID! No need to upload to get verified again! If you uploaded the wrong file then you need to delete this account and open a new one!&lt;/p&gt;'; 
              $upload_err = 1; 
          } 
          elseif(file_exists("$user_img_directory/$user.png")) 
          { 
              $error_msg['upload_img_error'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 5c: You have already uploaded an Image File to verify your ID! No need to upload to get verified again! If you uploaded the wrong file then you need to delete this account and open a new one!&lt;/p&gt;'; 
              $upload_err = 1; 
          } 
  
          //Uploading Video File 
          if(file_exists("$user_video_directory/$user.mp4")) 
          { 
              $error_msg['upload_video_error'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 5e: You have already uploaded a Video File to verify your ID! No need to upload to get verified again! If you uploaded the wrong file then you need to delete this account and open a new one!&lt;/&lt;/p&gt;'; 
              $upload_err = 1; 
          } 
          elseif(file_exists("$user_video_directory/$user.wav")) 
          { 
              $error_msg['upload_video_error'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 5f: You have already uploaded a Video File to verify your ID! No need to upload to get verified again! If you uploaded the wrong file then you need to delete this account and open a new one!&lt;/&lt;/p&gt;'; 
              $upload_err = 1; 
          } 
          if(file_exists("$user_video_directory/$user.wmv")) 
          { 
              $error_msg['upload_video_error'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 5e: You have already uploaded a Video File to verify your ID! No need to upload to get verified again! If you uploaded the wrong file then you need to delete this account and open a new one!&lt;/&lt;/p&gt;'; 
              $upload_err = 1; 
          } 
          elseif(file_exists("$user_video_directory/$user.flv")) 
          { 
              $error_msg['upload_video_error'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 5f: You have already uploaded a Video File to verify your ID! No need to upload to get verified again! If you uploaded the wrong file then you need to delete this account and open a new one!&lt;/&lt;/p&gt;'; 
              $upload_err = 1; 
          } 
          elseif(file_exists("$user_video_directory/$user.ogg")) 
          { 
              $error_msg['upload_video_error'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 5f: You have already uploaded a Video File to verify your ID! No need to upload to get verified again! If you uploaded the wrong file then you need to delete this account and open a new one!&lt;/&lt;/p&gt;'; 
              $upload_err = 1; 
          } 
  
          //Checking for NO errors to proceed with the script flow. 
          if($upload_err == 0) 
          { 
              //DIRECTORY PATHS AGAIN
              //1. $default_directory_path = 'uploads/id_verifications'; //Permanent Storage Directory Path. 
              //2. $default_directory_path_and_user_dir = "$default_directory_path"."/".$user; //Permanent Storage Directory Path for $user Folder. 
              //3. $user_img_directory = $default_directory_path_and_user_dir."."/".img'; 
              //4. $user_video_directory = $default_directory_path_and_user_dir."."/".videos';
  
              if(is_uploaded_file($img_file_tmp) &amp;&amp; is_uploaded_file($video_file_tmp)) 
              { 
                  if(move_uploaded_file($img_file_tmp,$user_id_img_file)) 
                  { 
                      rename($user_id_img_file,$user_img_directory.$user.'.'.$img_file_ext); 
                  } 
  
                  if(move_uploaded_file($video_file_tmp,$user_id_video_file)) 
                  { 
                      rename($user_id_video_file,$user_video_directory.$user.'.'.$video_file_ext); 
                  } 
  
                  $success_msg['all_uploads'] = 'SUCCESS STATEMENT 6a: Both Image and Video files have been uploaded successfully!'; 
              } 
              else 
              {        
                  $error_msg['all_uploads'] = 'ERROR STATEMENT 6b: Both Image and Video files failed to upload successfully! You may try again another time!'; 
                  exit(); 
              } 
          } 
      }
  }
  }
  ?&gt; 
  </code></pre>
  
  <p>4th Apr 2020 UPDATE:
  Folks,</p>
  
  <p>I updated the script but no luck. Problem remains.
  I get these errors:</p>
  
  <p>Warning: mime_content_type(loudgob.png): failed to open stream: No such file or directory in C:\xampp\htdocs\test\02-04-2020\upload_test.php on line 57</p>
  
  <pre><code>    Warning: mime_content_type(loudgob.mp4): failed to open stream: No such file or directory in C:\xampp\htdocs\test\02-04-2020\upload_test.php on line 63
  
      Warning: filesize(): stat failed for loudgob.png in C:\xampp\htdocs\test\02-04-2020\upload_test.php on line 72
  
      Warning: filesize(): stat failed for loudgob.mp4 in C:\xampp\htdocs\test\02-04-2020\upload_test.php on line 78
  </code></pre>
  
  <p>Full Update:</p>
  
  <pre><code>&lt;?php 
  
      $error_msg =  array(); 
      $success_msg =  array(); 
  
      $img_allowed_ext = array('png'); 
      $video_allowed_ext = array('mp4');  
  
      $img_mime_type =  array('image/png'); 
      $video_mime_type =  array('video/mp4'); 
  
      if($_SERVER["REQUEST_METHOD"] == "POST") 
      { 
          $error = 0 ; 
          //var_dump($_Files); //For debugging. 
  
  //Check whether the file was uploaded or not without any errors. 
  if(!isset($_FILES["id_verification_video_file"]) || !isset($_FILES['id_verification_img_file'])) 
  { 
      $error_msg['all_fields'] =  '&lt;p class="text-danger"&gt;ERROR STATEMENT 1: Select all fields that have asterisks besides them!&lt;/p&gt;'; 
      $error = 1;             
  } 
  else 
  { 
      //Image Files 
      $img_file_name = $_FILES["id_verification_img_file"]["name"]; 
      $img_file_tmp = $_FILES["id_verification_img_file"]["tmp_name"];
      $img_file_type = $_FILES["id_verification_img_file"]["type"]; 
      $img_file_size = $_FILES["id_verification_img_file"]["size"]; 
      $img_file_error = $_FILES['id_verification_img_file']['error']; 
  
      $img_file_ext = pathinfo($img_file_name, PATHINFO_EXTENSION); 
  
      //Video Files 
      $video_file_name = $_FILES["id_verification_video_file"]["name"]; 
      $video_file_tmp = $_FILES["id_verification_video_file"]["tmp_name"]; 
      $video_file_type = $_FILES["id_verification_video_file"]["type"]; 
      $video_file_size = $_FILES["id_verification_video_file"]["size"]; 
      $video_file_error = $_FILES['id_verification_video_file']['error']; 
  
      $video_file_ext = pathinfo($video_file_name, PATHINFO_EXTENSION); 
  
      //Checking File Type using pathinfo_extension() Function.       
      if(!in_array(pathinfo($img_file_name, PATHINFO_EXTENSION),$img_allowed_ext)) 
      { 
          $error_msg['img_error']= '&lt;p class="text-danger"&gt;ERROR STATEMENT 2a: Invalid File! Only jpg, jpeg, png and gif image files are allowed!'; 
          $error = 1; 
      } 
  
      if(!in_array(pathinfo($video_file_name, PATHINFO_EXTENSION),$video_allowed_ext)) 
      { 
          $error_msg['video_error'] =  '&lt;p class="text-danger"&gt;ERROR STATEMENT 2b: Invalid File! Only mp4, wav, ogg, flv, wmv and avi video files are allowed!'; 
          $error = 1; 
      }           
  
      //Checking Mime Type using mime_content_type() Function.        
      if(!in_array(mime_content_type($img_file_name),$img_mime_type)) 
      { 
          $error_msg['img_error']= '&lt;p class="text-danger"&gt;ERROR STATEMENT 3a: Invalid File! Only jpg, jpeg, png and gif image files are allowed!'; 
          $error = 1; 
      }       
  
      if(!in_array(mime_content_type($video_file_name),$video_mime_type)) 
      { 
          $error_msg['video_error'] =  '&lt;p class="text-danger"&gt;ERROR STATEMENT 3b: Invalid File! Only mp4, wav, ogg, flv, wmv and avi video files are allowed!'; 
          $error = 1; 
      } 
  
  
      //Checking File Sizes using filesize() function. 
      //5MB Image Size Allowed. 
      if(filesize($img_file_name) &gt; 5000000) 
      { 
          $error_msg['img_file_size_err'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 4a: File Size is greater than 5MB. File Size should not exceed the 100MB limit!'; 
          $error = 1; 
      } 
      //10MB Video Size Allowed.          
      if(filesize($video_file_name) &gt; 10000000) 
      { 
          $error_msg['video_file_size_err'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 4b: File Size is greater than 10MB. File Size should not exceed the 100MB limit!';  
          $error = 1; 
      }           
  
      //Checking for NO errors to proceed with the script flow. 
      if($error == 0)
      { 
          $user = $user; //Account Username here. 
          //$db_user = 'followingbrowser_user'; //Database username here. Has to be in quotes. 
          $db_user = 'root'; //Database username here. Has to be in quotes. 
          //Feed Id Verification Video &amp; Image File Upload Directory path. 
          $default_directory_path = 'uploads/id_verifications'; //Permanent Storage Directory Path. 
          $default_directory_path_and_user_dir = "$default_directory_path"."/"."$user"; //Permanent Storage Directory Path for $user Folder. 
  
          //Create $user Folder in Permanent Storage Directory Path: 'uploads/videos/id_verifications' Folder.                
          if(!is_dir($default_directory_path_and_user_dir)) 
          {               
              //$db_user = 'followingbrowser_user'; //Has to be in quotes. 
              $db_user = 'root'; //Has to be in quotes. 
              $mode = 0755; 
              mkdir($default_directory_path_and_user_dir,$mode,TRUE); //This line is working and is correct even without quoting "$mode". Requinix sugegsted to quote "$mode". 
          } 
  
         //Making Directories of every Files Types for Respective User.               
          $user_img_directory = "$default_directory_path_and_user_dir"."/"."imgs"; 
          $user_video_directory = "$default_directory_path_and_user_dir"."/"."videos"; 
  
          if(!is_dir($user_img_directory)) 
          { 
              //$db_user = 'followingbrowser_user'; //Has to be in quotes. 
              $db_user = 'root'; //Has to be in quotes. 
              $mode = 0755; 
              mkdir($user_img_directory,$mode,TRUE); //This line is correct and working even without quoting $mode.
          } 
  
          if(!is_dir($user_video_directory)) 
          { 
              //$db_user = 'followingbrowser_user'; //Has to be in quotes. 
              $db_user = 'root'; //Has to be in quotes. 
              $mode = 0755; 
              mkdir($user_video_directory,$mode,TRUE); //This line is correct and working even without quoting $mode. 
          }               
  
          //User Files Directories. 
          $default_directory_path = 'uploads/id_verifications'; //Permanent Storage Directory Path. 
          $default_directory_path_and_user_dir = "$default_directory_path"."/"."$user"; //Permanent Storage Directory Path for $user Folder. 
          $user_img_directory = "$default_directory_path_and_user_dir"."/"."img"; 
          $user_video_directory = "$default_directory_path_and_user_dir"."/"."videos"; 
          $user_id_img_file = "$user_img_directory"."/"."$img_file_name"."$img_file_ext"; 
          $user_id_video_file = "$user_video_directory"."/"."$video_file_name"."$video_file_ext"; 
  
          //Uploading the Files. 
          $upload_err =  0; 
  
          //Uploading Image File 
          if(file_exists("$user_img_directory/$user.png")) 
          { 
              $error_msg['upload_img_error'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 5c: You have already uploaded an Image File to verify your ID! No need to upload to get verified again! If you uploaded the wrong file then you need to delete this account and open a new one!&lt;/p&gt;'; 
              $upload_err = 1; 
          } 
  
          //Uploading Video File 
          if(file_exists("$user_video_directory/$user.mp4")) 
          { 
              $error_msg['upload_video_error'] = '&lt;p class="text-danger"&gt;ERROR STATEMENT 5e: You have already uploaded a Video File to verify your ID! No need to upload to get verified again! If you uploaded the wrong file then you need to delete this account and open a new one!&lt;/&lt;/p&gt;'; 
              $upload_err = 1; 
          } 
  
          //Checking for NO errors to proceed with the script flow. 
          if($upload_err == 0) 
          { 
              //DIRECTORY PATHS AGAIN
              //1. $default_directory_path = 'uploads/id_verifications'; //Permanent Storage Directory Path. 
              //2. $default_directory_path_and_user_dir = "$default_directory_path"."/".$user; //Permanent Storage Directory Path for $user Folder. 
              //3. $user_img_directory = $default_directory_path_and_user_dir."."/".img'; 
              //4. $user_video_directory = $default_directory_path_and_user_dir."."/".videos';
  
              if(is_uploaded_file($img_file_tmp) &amp;&amp; is_uploaded_file($video_file_tmp)) 
              { 
                  if(move_uploaded_file($img_file_tmp,$user_id_img_file)) 
                  { 
                      rename($user_id_img_file,$user_img_directory.$user.'.'.$img_file_ext); 
                  } 
  
                  if(move_uploaded_file($video_file_tmp,$user_id_video_file)) 
                  { 
                      rename($user_id_video_file,$user_video_directory.$user.'.'.$video_file_ext); 
                  } 
  
                  $success_msg['all_uploads'] = 'SUCCESS STATEMENT 6a: Both Image and Video files have been uploaded successfully!'; 
              } 
              else 
              {        
                  $error_msg['all_uploads'] = 'ERROR STATEMENT 6b: Both Image and Video files failed to upload successfully! You may try again another time!'; 
                  exit(); 
              } 
          } 
      }
  }
      }
      ?&gt; 
  </code></pre>
  
  <p>Why is it unable to find the file ? I browsed to the files and selected them. Both png and mp4 files.</p>