php - large csv file not uploaded to database -
i having csv file 30000 data trying upload data mysql not uploading data mysql.
but if try small data 100 data uploading database .
can me how make work
below code
my upload.php
<?php include("db.php"); //upload file $sql="select max(upload_id) contact"; $result=mysqli_query( $mysqli,$sql); $row = mysqli_fetch_array($result); $highest_id = $row[0]; //print $highest_id; $uploadid = $highest_id+1; //print $uploadid; $dropdown = $_post['drop']; print $dropdown; if (isset($_post['submit'])) { //import uploaded file database $file = $_files['filename']['tmp_name']; $handle = fopen($file,"r"); ($lines = 0; $data = fgetcsv($handle,1000,",",'"'); $lines++) { if ($lines == 0) continue; ($i = 0; $i <= 32; $i ++) { if (!isset($data[$i])) $data[$i] = ''; } $import="insert contact (name, contacttype, nationality, mobile1, country1,`mobile2`,`country2`, email1,`email2`, phone, fax,`country3`, twon, area, restatus, retype, reproject1, contactgroup, freezone1, gender, dateofbirth, married, children, educationlevel, jobrole, jobsector, driverslicense, language,media, media2, media3, media4, age, salary, created, upload, image, companyname, businesscategory, subcategory, upload_id) values('$data[0]', '$data[1]','$data[2]','$data[3]', '$data[4]', '$data[5]','$data[6]','$data[7]', '$data[8]','$data[9]','$data[10]','$data[11]', '$data[12]','$data[13]','$data[14]','$data[15]', '$data[16]','$data[17]','$data[18]','$data[19]', '$data[20]','$data[21]','$data[22]','$data[23]', '$data[24]','$data[25]','$data[26]','$data[27]','$data[28]','$data[29]','$data[30]', '$data[31]','$data[32]','$data[33]',".time().",'$data[35]','$data[36]','$data[37]', '$data[38]','$data[39]','$data[17]') "; print $import; mysqli_query( $mysqli,$import) or trigger_error("query failed! sql: $sql - error: ".mysqli_error(), e_user_error); //view upload form } fclose($handle); print "import done"; //header("location: /uploadanddelete.php"); }else { print "import failed"; } ?>
my uploaddata.php
<p>upload new csv browsing file , clicking on upload </p> <form enctype='multipart/form-data' action="upload.php" method="post" class='form-horizontal form-column form-bordered'> <p>file name import: <input size='50' type='file' name='filename'><br /><br /> </p> <input type="submit" name="submit" value="upload"/> </form>
it looks ok there can problems:
is file uploaded?
no: check upload_max_filesize , post_max_size in php.ini
is imported lines or no import line when have big file?
no: check memory_limit (php.ini) can increase this:
ini_set('memory_limit','16m');
yes: check max_execution_time (php.ini) can increase this:
set_time_limit ($seconds)
if doesn't try debug in part of code dyinig
Comments
Post a Comment