I am having a problem with a csv file upload where the csv file is not being uploaded onto the server and therefore cannot be 'read' and inserted in mysql database.
Can anyone see where I am going wrong - thanks
session_start ();
$_SESSION['username'] = $username;
require_once ('../mysql_connect.php'); //connect to the database
ini_set('memory_limit', '20M');
ini_set("max_execution_time", 0);
// 1- upload user
$uploadDir = '/home/xxx/yyy/htdocs/upload/';
$uploadFile = $uploadDir . $_FILES['UserCsvFile']['name'];
print "<pre>";
$filename = $_FILES['UserCsvFile']['tmp_name'];
$fp = fopen($filename,"rb") or die ('Could Not Open User File!');
while (!feof($fp))
{
$data = fgetcsv($fp,1000000);
$UserRef = addslashes($data[0]);
$ConcesRef = addslashes($data[1]);
$ClientRef = addslashes($data[2]);
$CName = addslashes($data[3]);
$CLogIn = addslashes($data[4]);
$CPass = addslashes($data[5]);
$CEmail = addslashes($data[6]);
$Removed = addslashes($data[7]);
$sql = "REPLACE INTO tblUser (UserId, ConcesRef, ClientRef, UName, ULogIn, UPassword, UEmail, Removed)
VALUES ('$UserRef', '$ConcesRef', '$ClientRef', '$CName', '$CLogIn', '$CPass', '$CEmail', '$Removed')";
$result = mysql_query($sql)
or die(mysql_error());
}
if (move_uploaded_file($_FILES['UserCsvFile']['tmp_name'], $uploadFile))
{ echo '<div align="center">
<p> </p>
<p> </p>
<p><b><font color="#FF6600" face="Arial, Helvetica, sans-serif" size="4">Thank You, <br> The new User Data has been added to the database</font></b></p>
<p></p></div>';
}
else
{
print "Not Possible To Upload User Data! Please Try Again";
}
print "</pre>";