0

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.";
}
?>
-----------------------------------------------------------------

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by uselessninja
0

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.


this is the error that the php gave if the file is not existing into the folder.
to resolve this, check your directory first by using "echo"
example:
$variable = move_uploaded_file($_FILES, $target);
echo $variable;
if the output is "1" it means that the file is present in directory.
if the output is the same as the error you've encounter, put "../" on the first statement.
example "../foldername/file"

0

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.


this is the error that the php gave if the file is not existing into the folder.
to resolve this, check your directory first by using "echo"
example:
$variable = move_uploaded_file($_FILES, $target);
echo $variable;
if the output is "1" it means that the file is present in directory.
if the output is the same as the error you've encounter, put "../" on the first statement.
example "../foldername/file"

i try your suggestion i add the path whith ..../foldername/file(the one you've suggesterd) yeah it workss..... BUT it didnt display everything...

take a look....
>>>>>http://i56.tinypic.com/seu8uf.jpg<<<<<<<

0

btw............ i use cpanel mysql as my image storage and it is only 1gb... is it okay?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.