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)