Hello
I am working through the file upload handling section of the php manual and have got confused, can anyone help me out.....
I need to upload a .csv file from a remote user, take this information and input the data into the mysql database.
I know I have first upload the file to the local server so it can be found.....
I have created a html form as follows;
<form name="form1" method="post" action="client_upload.php" enctype="multipart/form-data">
<p>
<input type="hidden" name="MAX_FILE_SIZE" value="600M">
<input type="file" name="ClientCsvFile" size="50">
</p>
<p align="center">
<input type="submit" name="Submit" value="INSERT DATA">
</p>
</form>
The code in file client_upload.php is as follows;
<?php
require_once ('../mysql_connect.php'); //connect to the database
$uploadfile = $_FILES['ClientCsvFile']['name'];
$fp = fopen ("$uploadfile","wb") or die('could not open file!');
while (!feof($fp)){
$data = fgetcsv($fp,5000);
$ClientId = $data[0];
$ConcesRef = $data[1];
$CoName = $data[2];
$Addr1 = $data[3];
$Addr2 = $data[4];
$Addr3 = $data[5];
$Town = $data[6];
$County = $data[7];
$Postcode = $data[8];
$Phone = $data[9];
$Fax = $data[10];
$sql = "REPLACE INTO tblClient (ClientId, ConcesRef, CoName, Addr1, Addr2, Addr3, Town, County, Postcode, Phone, Fax)
VALUES ('$ClientId', '$ConcesRef', '$CoName', '$Addr1', '$Addr2', '$Addr3', '$Town', '$County', '$Postcode', '$Phone', '$Fax')";
$result = mysql_query($sql)
or die(mysql_error());
}
Running this I get the following error message
Warning: fopen(Client.csv): failed to open stream: Permission denied in /h/ej/6/ht/888/888os/upload/client_upload.php on line 10
line 10 is
$fp = fopen ("$uploadfile","wb") or die('could not open file!');
then I get my error message
could not open file!
where am I going wrong?
TIA