|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /proc/21571/root/home/queenjbs/www/test/csvupload/ |
Upload File : |
<?include $_SERVER['DOCUMENT_ROOT']."/conf/conf_dir.php";?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlusĀ®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
</head>
<body>
<table width="600">
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" enctype="multipart/form-data">
<tr>
<td width="20%">Select file</td>
<td width="80%"><input type="file" name="file" id="file" /></td>
</tr>
<tr>
<td>Submit</td>
<td><input type="submit" name="submit" /></td>
</tr>
</form>
</table>
</body>
</html>
<?
if ( isset($_POST["submit"]) ) {
if ( isset($_FILES["file"])) {
//if there was an error uploading the file
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
$handle = fopen($_FILES["file"]["tmp_name"], "r");
$i=0;
while (($data = fgetcsv($handle, 4096, ',','"')) !== FALSE) {
for($j=0;$j<count($data);$j++)
{
$data[$j] = str_replace("\"","",$data[$j]);
}
echo "<br/>";
print_r($data);
//echo "<br/>";
echo $queryupok2 = "INSERT INTO `AUCTION_EVENT5` (`no`, `goodName`, `reg_date`, `goodsNum`, `price`, `bidder`, `user`, `addr`, `tel`, `email`) VALUES ('$data[0]', '$data[1]', '$data[2]', '$data[3]', '$data[4]', '$data[5]', '$data[6]', '$data[7]', '$data[8]', '$data[9]')";
//echo "<br/>";
//$queryupok_result = mysql_query($queryupok2,$db_con);
}
}
} else {
echo "No file selected <br />";
}
}
?>