Last active
September 5, 2016 08:06
-
-
Save majumawm/760784fcf464c1658093d7b7d389f259 to your computer and use it in GitHub Desktop.
fileupload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<form action="upload.php" method="post" enctype="multipart/form-data"> | |
Select image to upload: | |
<input type="file" name="userfile" id="userfile"> | |
<input type="submit" value="Upload Image" name="submit"> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$uploaddir = 'uploads/'; | |
$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:'; | |
var_export($_FILES); | |
echo "</pre>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment