我想将CSV文件上传到mysql数据库,但我得到错误可以任何人帮助我,请我是新的PHP 警告:fopen()[function.fopen]:文件名不能为空
这是代码请帮帮我
<?php
$connect = mysql_connect("localhost","root","");
mysql_select_db("csv",$connect);
?>
<?php
//Upload File
if (isset($_POST['submit'])) {
if (is_uploaded_file($_FILES['filename']['tmp_name'])) {
echo "<h3>" . "File ". $_FILES['filename']['name'] ." uploaded successfully." ."</h3>";
}
//Import uploaded file to Database
$handle = fopen($_FILES['filename']['tmp_name'], "r");
$firstRow = true;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($firstRow) { $firstRow = false; }
else {
$import="INSERT into product_details(pname,price,total) values('$data[0]','$data[1]','$data[2]')";
mysql_query($import) or die(mysql_error());
}
}
fclose($handle);
print "Import done";
}其他{?&gt;
<h3>Upload new csv by Browsing to file and Clicking on Upload</h3><br />
<form enctype="multipart/form-data" action='' method='post'>
<input type="file" name="filename" onchange="checkfile(this);" ><br /><br />
<input class="btn btn btn-primary" type="submit" name="submit" value="Upload">
</form>
提前谢谢