I am trying to show a progress bar or something similar just to keep the user busy while the data from the csv to mysql table using php. Below is the code that is called when pressing the import button:
if(isset($_POST['importSubmit'])){
//validate whether uploaded file is a csv file
$csvMimes = array('application/vnd.ms-excel','text/plain','text/csv','text/tsv');
if(!empty($_FILES['file']['name']) && in_array($_FILES['file']['type'],$csvMimes)){
if(is_uploaded_file($_FILES['file']['tmp_name'])){
//open uploaded csv file with read only mode
$csvFile = fopen($_FILES['file']['tmp_name'], 'r');
//skip first line
fgetcsv($csvFile);
//parse data from csv file line by line
while(($line = fgetcsv($csvFile)) !== FALSE){
//insert member data into database
$db->query("INSERT INTO members (name, email) VALUES ('".$line[0]."','".$line[1]."')");
}
//close opened csv file
fclose($csvFile);
echo $status_s;
}else{
echo $status_e;
}
}else{
echo $status_f;
}
}