Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to check if uploading file is in .csv extension using PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2.25k
    Comment on it

    Hello Reader!, If you are looking for verify the uploading file with the correct extension with .csv only. Then you use the PHP code as below:-

    $allowed =  array('csv'); //you can mentions all the allowed file format you need to accept, like .jpg, gif.
    $filename = $_FILES['csv_file']['name']; // csv_file is the file name on the form
    $ext = pathinfo($filename, PATHINFO_EXTENSION);
    
    if(!in_array($ext,$allowed) ) {
    
      $this ->session->set_flashdata('msg','Please Upload Files With .CSV Extenion Only, Error Code: 0');
     // you can make the user redirect to back page with you custom error
         redirect(base_url().'welcome/MyContacts','refresh');
    }
    

    And it will work perfect for file having .csv extension

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: