I rookie just learn PHP want to write an upload image program
$myPicture =$_files[' mypicture '];
Print_r ($myPicture);
$error = $myPicture [' ERROR '];
echo "Error:
";
Switch ($error) {
Case 0://You need to move the temp file to the specified location.
$myPictureName = $myPicture [' name '];
Var_dump ($myPictureName);
echo "
";
$tmp _name= $myPicture [' Tmp_name '];
$destination = "uploads/". $myPictureName;
Echo $destination;
Move_uploaded_file ($tmp _name, $destination);
echo "File upload succeeded";
Break
Case 1:
echo "error number 1th";
Break
Case 2:
echo "error number 2nd";
Break
Case 3:
echo "error number 3rd";
Break
Case 4:
echo "Error number 4th";
Break
Default
echo "Failure";
Here are the error hints:
Warning:move_uploaded_file (uploads/xx.jpg) [Function.move-uploaded-file]: failed to open stream:no such file or Directo Ry in D:\Apache\test\register1.php on line 31
Warning:move_uploaded_file () [Function.move-uploaded-file]: Unable to move ' C:\Windows\Temp\php25F.tmp ' to ' uploads/ Xx.jpg ' in D:\Apache\test\register1.php on line 31
Reply to discussion (solution)
Error two parameters for Move_uploaded_file ()
$destination Write an absolute path test
$destination = "uploads/". $myPictureName;
Change?
$destination =dirname (__file__). " /uploads/". $myPictureName;
??
D:\Apache\test\ ' uploads directory does not exist
Thank you very much or because you didn't create a path. But I tried it on the first and second floor.
??? What's wrong with my knot?