I have this code that imports data from a csv file into mysql, but when i run it I get an error message
Warning: move_uploaded_file(/home/===/---/000/upload/Client1.csv) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/===/---/000/upload/client_upload.php on line 90
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpthgkuk' to '/home/home/===/---/000/upload/Client1.csv' in /home/===/---/000/upload/client_upload.php on line 90
Not Possible To Upload Data! Please Try Again
it says that the import didn't work, but when you check the database it has worked and the new / amended records are there.
I need to get to the bottom of this as the error message fills the screen the user sees (which is bad!)
thanks in advance
my code is
$uploadDir = '/home/===/---/000/upload/';
$uploadFile = $uploadDir . $_FILES['ClientCsvFile']['name'];
print "<pre>";
$filename = $_FILES['ClientCsvFile']['tmp_name'];
$fp = fopen($filename,"rb") or die('could not open file!');
while (!feof($fp)){
$data = fgetcsv($fp,500000);
$ClientId = addslashes($data[0]);
$ConcesRef = addslashes($data[1]);
$CoName = addslashes($data[2]);
$Addr1 = addslashes($data[3]);
$Addr2 = addslashes($data[4]);
$Addr3 = addslashes($data[5]);
$Town = addslashes($data[6]);
$County = addslashes($data[7]);
$Postcode = addslashes($data[8]);
$Phone = addslashes($data[9]);
$Fax = addslashes($data[10]);
$Removed = addslashes($data[11]);
$RemovedBy = addslashes($data[12]);
$sql = "REPLACE INTO tblClient (ClientId, ConcesRef, CoName, Addr1, Addr2, Addr3, Town, County, Postcode, Phone, Fax, Removed, RemovedBy)
VALUES ('$ClientId', '$ConcesRef', '$CoName', '$Addr1', '$Addr2', '$Addr3', '$Town', '$County', '$Postcode', '$Phone', '$Fax', '$Removed', '$RemovedBy')";
$result = mysql_query($sql)
or die(mysql_error());
$sql1 = "DELETE FROM tblClient WHERE ConcesRef = 0";
$result1 = mysql_query($sql1)
or die(mysql_error());
}
if (move_uploaded_file($_FILES['ClientCsvFile']['tmp_name'], $uploadFile))
{ echo '<div align="center">
Thank You, <br> The new Client Data has been added to the database
</div>';
}
else
{
print "Not Possible To Upload Data! Please Try Again";
}
print "</pre>";