csv改良时出现问题 [英] problem while impoorting csv
本文介绍了csv改良时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
实际上,我必须导入一个csv文件,并且该数据要存储在数据库中.我已经成功完成了..但是我在其中添加了一个用于csv文件类型的验证.如果该文件不是csv,则应该不能导入..我对此文件进行了编码..但仅在mozila-firefox中才成功.其他浏览器给我一些错误..请帮助我..这是我的代码..
Actually I have to import a csv file and that data want to store in database..I ve done it successfully.. but I add one validation there for type of csv file.if the file any other than csv then it should not be imported.. I did coding for this file..but it is successful only in mozila-firefox . Other browser giving some error to me..Please help me..Here is my code..
if (isset($_POST['load']))
{
if ( isset($_FILES["file"]))
{
if ($_FILES["file"]["error"] > 0)
{
echo "<p><font color='red'>No File Selected </p></font> <br />";
}
else
{
$file_name = $_FILES["file"]["name"];
if($_FILES["file"]["type"] != "text/csv")
{
die("<p><font color='red'>This is not a CSV file.</p></font>");
}
else
{
$location="C:\\xampp\\mysql\\data\\import\\";
move_uploaded_file($_FILES["file"]["tmp_name"], $location . $_FILES["file"]["name"]);
}
}
$counter=0;
$handle = fopen($location . $_FILES["file"]["name"], 'r');
问题出在
Problem is at
$file_name = $_FILES["file"]["name"];
if($_FILES["file"]["type"] != "text/csv")
{
die("<p><font color='red'>This is not a CSV file.</p></font>");
}
但我不知道该怎么解决?
but i dnt know how to solve it??
推荐答案
_POST [' 如果(isset(
_POST['load'])) { if ( isset(
_FILES [" 文件"])) { 如果(
_FILES["file"])) { if (
_FILES [" ] [" ]> 0) { echo " ; } 其他 {
_FILES["file"]["error"] > 0) { echo "<p><font color='red'>No File Selected </p></font> <br />"; } else {
这篇关于csv改良时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文