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??