[英]I have an error while uploading csv file
I can read the csv file form localhost, Once I move to online It show's error Warning: fopen(boo1.csv): failed to open stream: No such file or directory in /home/ashishco/public_html/group/fetchCsv.php on line 28, 我可以从本地主机读取csv文件,一旦我进入在线状态,它显示错误警告:fopen(boo1.csv):无法打开流:/home/ashishco/public_html/group/fetchCsv.php中没有此类文件或目录第28行,
I don't know how to give path. 我不知道该怎么走
<?php
include("includes/connection.php");
include("includes/mail.php");
if(isset($_POST["Import"]))
{
echo $filename=$_FILES["file"]["name"];
//echo $ext=substr($filename,strrpos($filename,"."),(strlen($filename)-strrpos($filename,".")));
mysql_query("CREATE TABLE IF NOT EXISTS mytable (
`MId` bigint(20) NOT NULL AUTO_INCREMENT,
`Batch` varchar(50) NOT NULL,
`Department` varchar(50) NOT NULL,
`RegisterNo` varchar(50) NOT NULL,
`Name` varchar(200) NOT NULL,
`EmailId` varchar(250) NOT NULL,
`Password` varchar(50) NOT NULL,
`MobileNo` int(50) NOT NULL,
`Status` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`MId`)
)");
if($_FILES["file"]["size"] > 0)
{
$file = fopen($filename, "r");
$count=1;
while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
{
//print_r($emapData);
if($count>1)
{
$sql = "INSERT into myTable(Batch,Department,RegisterNo,Name,EmailId,Password,MobileNo) values('$emapData[0]','$emapData[1]','$emapData[2]','$emapData[3]','$emapData[4]','$emapData[5]','$emapData[6]')";
//echo $sql;
mysql_query($sql);
}
$count++;
}
//die();
fclose($file);
echo "CSV File has been successfully Imported";
fnSendMail();
}
else
{
echo "Invalid File:Please Upload CSV File";
}
}
?>
you should give your path like this 你应该给你这样的道路
$file = fopen("/ your path/".$filename, "r");
Suppose your csv file have path as /home/group/file.csv and your php file have path as /home/yourphp.php then you will call as 假设您的csv文件的路径为/home/group/file.csv,而php文件的路径为/home/yourphp.php,那么您将调用为
$file = fopen("/group/".$filename, "r");
in your case just use as 在你的情况下只是用作
$file = fopen($filename, "r");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.