hi i have a code that uploads an image...but it gives me an error when i upload a photo:
Warning: move_uploaded_file(test/ssss.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\xampp\htdocs\test\add.php on line 21
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\php163.tmp' to 'test/ssss.jpg' in C:\xampp\htdocs\test\add.php on line 21
Sorry, there was a problem uploading your file.
ohh btw.. this is my code:
--------------------------------html--------------------------------------
<form enctype="multipart/form-data" action="add.php" method="POST">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name = "email"><br>
Phone: <input type="text" name = "phone"><br>
Photo: <input type="file" name="photo"><br>
<input type="submit" value="Add">
</form>
---------------------------------------------------------------------------
---------------------------------PHP (for adding pic)----------------------------------------
<?php
//This is the directory where images will be saved
$target = "test/";
$target = $target . basename( $_FILES);
//This gets all the other information from the form
$name=$_POST;
$email=$_POST;
$phone=$_POST;
$pic=($_FILES);
// Connects to your Database
mysql_connect("localhost", "xxx", "xxx") or die(mysql_error()) ;
mysql_select_db("simulation") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES, $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES). " 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.";
}
?>
-----------------------------------------------------------------