I am trying to import csv file to wordpress using database.the files are uploaded in database but its not coming in wordpress .
The code is as below:
<?php
if(isset($_POST['submit']))
{
$fname=$_FILES["file"]["name"];
$datetime=$_FILES["file"][""];
$chk_ext = explode(".",$fname);
if(strtolower(($chk_ext[1]) == "csv"))
{
$filename = $_FILES['file']['tmp_name'];
$handle = fopen($filename, "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$fname=addslashes($data[0]);
$datetime=addslashes($data[1]);
$products=addslashes($data[2]);
$preset=addslashes($data[3]);
$format=addslashes($data[4]);
$sql = "INSERT into ".$wpdb->prefix ."facebook(filename,datetime,products,preset,format) values('$fname','$datetime','$products','$preset','$format')";
mysql_query($sql) or die(mysql_error());
}
fclose($handle);
echo "Successfully Imported";
}
else
{
echo "Invalid File";
}
}
?>
<form enctype="multipart/form-data" action="" method="post" name="uploadDetails">
<table cellpadding="4" cellspacing="0" border="1">
<tr>
<td><label for="upload_a_file">Upload File:</label></td>
<td><input type="file" name="file" id="upload_a_file" /></td>
</tr>
<tr>
</tr>
</table>
<input type="hidden" name="fd_upload" value="1" />
<input type="submit" value="Submit" class="allbutton" name="submit" />
</form>
Hope you will help me