Here is my HTML code :
<form enctype="multipart/form-data" action="new1.php" method="POST">
Choose File: <input name="userfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
And this is my PHP code :
<?php
$path = "files/";
$path = $path.basename( $_FILES['userfile']['name']);
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $path)) {
echo "Success uploading". basename($_FILES['userfile']['name']);
} else{
echo "Error when uploading file.";
}
?>
Here are the errors I got when running on XAMPP
Warning: move_uploaded_file(files/ChicKissLove.jpg): failed to open stream: No such file or directory in C:\xampp\htdocs\phptest
ew1.php on line 7
Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\phpAF97.tmp' to 'files/ChicKissLove.jpg' in C:\xampp\htdocs\phptest
ew1.php on line 7
Error when uploading file.
Anyone can find out what's wrong ? I 'm unable to upload the files.