php - Yii:Upload CSV file to database -
i'm trying save csv file database , finding issues it.
controller:
$mod = new csv; if(isset($_post['csv'])) { $mod->attributes=$_post['csv']; if(!empty($_files['csv']['tmp_name']['csv'])) { $file = cuploadedfile::getinstance($mod,'csv'); $fp = fopen($file->tempname, 'r'); if($fp) { { $line = fgetcsv($fp, 1000, ","); echo $line[0]; echo $line[1]; $mod['mobile'] = $line[0]; $mod['name'] = $line[1]; $mod->insert(); } while( ($line = fgetcsv($fp, 1000, ";")) != false); } }}
i'm able store first record of csv file. other records stored null. dont know i'm missing here
Comments
Post a Comment