Skip to content

Instantly share code, notes, and snippets.

@majumawm
Last active September 5, 2016 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save majumawm/760784fcf464c1658093d7b7d389f259 to your computer and use it in GitHub Desktop.
Save majumawm/760784fcf464c1658093d7b7d389f259 to your computer and use it in GitHub Desktop.
fileupload
<!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>
<?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