I make a admin page to upload the csv file into mysql. The file csv has size 59,9mb. But my script didn't upload the file into mysql. Would you mind to help me to fix this problem? Here is my code :
<HTML>
<HEAD>
<TITLE> Admin Update </TITLE>
</HEAD>
<BODY>
<form enctype='multipart/form-data' action="<?php echo $PHP_SELF ?>" method='post'>
<font face=arial size=2>Type file name to import:</font><br>
<input type='file' name='filename' size='20'><br>
<input type='submit' name='submit' value='submit'></form>
<?php
include("phpsqlajax_dbinfo.php");
$connection = mysql_connect ('127.0.0.1', $username, $password);
if (!$connection) { die('Not connected : ' . mysql_error());}
$db_selected = mysql_select_db("ipcoba", $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
if(isset($_POST['submit']))
{
// address to copy csv file
$target_path = "C:/xampp/htdocs/bikinwebtracert";
$target_path = $target_path . basename( $_FILES['filename']['name']);
if(move_uploaded_file($_FILES['filename']['tmp_name'], $target_path)) {
echo "<font face=arial size=2>The file ". basename( $_FILES['filename']['name']). " Upload Success</font><br>";
} else{
echo "<font face=arial size=2>Failed to Upload, Please try again</font><br>";
}
$filename=$target_path;
$load=mysql_query("LOAD DATA LOCAL INFILE $filename INTO TABLE CityBlocks FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' IGNORE 2 LINES (startIpNum, endIpNum, locId)'\n' ") or die(mysql_error());
if ($load){
echo("Failed");
} else {
echo("Success");
}
}
?>
</BODY>
</HTML>
I need to fix this problem as soon as possible. Please Help. Thank You.