there is a large csv file need to be import to mysql database
there are to ways bellow
1 , upload this csv file using a php then
<?php
$row = 1;
$handle = fopen("test.csv","r");
while ($data = fgetcsv($handle, 1000, ",")) {
// record rows to to database
}
fclose($handle);
?>
this way is easy ,but waiting for a long time
2, upload this csv file using a php
then use ajax to record each row of the csv and output the ajax feedback
<script type="text/javascript">
var row =0;
$.ajax({
url:"csv_to_db.php", //record only one row
type:"POST",
data:{
row : row;
},
success:function(){
row++;
}
});
</script>
this way can see the active feedback ajax info ,and the browser will not die when the method 1 wait too long time
but this way will excute fgetcsv function in "scv_to_db.php" every time, seems waiting the cpu and memery