|
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/21573/task/21573/root/home/queenjbs/www/test/csvupload/ |
Upload File : |
<!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("\"","",iconv("euc-jp","UTF-8", $data[$j]));
//$data[$j] = str_replace("\"","",$data[$j]);
}
echo "<br/>";
print_r($data);
}
}
} else {
echo "No file selected <br />";
}
}
?>