I'm trying to upload an image to my server as follow:
HTML CODE
<html>
<body>
<form enctype="multipart/form-data" action="uploadimages.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
</body>
</html>
Here is the uploadimages.php code: I also tried with: $uploaddir = '/var/www/html/images/'; and have the same issue.
<?php
$uploaddir = 'http://localhost/images/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
But when I click the button to send file I get the following screen:
Thank you for your help
UPDATE:
So I changed:
<form enctype="multipart/form-data" action="uploadimages.php" method="POST">
to
<form enctype="multipart/form-data" action="http://localhost/uploadimages.php" method="POST">
Now I get this error: