PHP warning

I have this short script to upload files and data.


//This is the directory where images will be saved 

$target = "images/"; $target = $target . basename( $_FILES['photo']['name']); 

//This gets all the other information from the form 

$name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $pic=($_FILES['photo']['name']); 

$con = mysql_connect("xxxxxxxxx","xxxxxxxxx","xxxxxxxxxx");
if (!$con)
  die('Could not connect: ' . mysql_error());
mysql_select_db("xxxxxxxxx", $con);

//Writes the information to the database 

mysql_query("INSERT INTO `gallery` VALUES ('$name', '$email', '$phone', '$pic')") ; 

//Writes the photo to the server 

if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { 
//Tells you if its all ok 

echo "The file ". basename( $_FILES['uploadedfile']['name']). 

" has been uploaded, and your information has been added to the directory"; } 

else { 
//Gives and error if its not 

echo "Sorry, there was a problem uploading your file."; } 



I always get this error and can’t seem to make it go away. There is a directory called “images” on the server at the root level.

Here’s the error…

Warning: move_uploaded_file(images/favicon.gif) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/fhlinux009/n/ on line 24

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘/tmp/phpfpCvah’ to ‘images/favicon.gif’ in /home/fhlinux009/n/ on line 24
Sorry, there was a problem uploading your file.

Can anyone spot where 'm going wrong please?

That error has now gone :slight_smile: But the images still aren’t writing to the server. I just made a new thread as I have changed the script a little bit.

I do have the correct permissions.

Thanks for the help so far.

That error suggests that ‘images/’ either doesn’t exist in the current working directory or it does not have the correct permissions.