I am trying to make a simple uploading application from a web page:localhost/test.html. I am getting these errors:
Warning: move_uploaded_file(test/Blue hills.jpg): failed to open stream:
No such file or directory in C:\wamp\www\test.html on line 11
and
Warning: move_uploaded_file(): Unable to move ‘C:\wamp\tmp\php376.tmp’
to ‘test/Blue hills.jpg’ in C:\wamp\www\test.html on line 11
Here is my code
<html>
<form enctype="multipart/form-data" action="test.html" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
<html>
<?php
$target = "test/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else {
echo "Uploading Error.";
}
Probably the directory
testdoesn’t exist. Add these lines to your code.