Skip to content

Instantly share code, notes, and snippets.

@amriunix
Last active August 9, 2022 07:00
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 amriunix/a8dc7f8685c211c8421859ed0208039d to your computer and use it in GitHub Desktop.
Save amriunix/a8dc7f8685c211c8421859ed0208039d to your computer and use it in GitHub Desktop.
PHP Upload file
<!DOCTYPE html>
<html>
<head>
<title>Upload your files</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<p>Upload your file</p>
<input type="file" name="file"></input><br />
<input type="submit" value="Upload"></input>
</form>
</body>
</html>
<?PHP
// https://stackoverflow.com/questions/2184513/change-the-maximum-upload-file-size
// Please adjust the maximum allowed size (upload_max_filesize) for uploaded and post request (post_max_size) in the php.ini file
if(!empty($_FILES['file']))
{
$path = "./";
$path = $path . basename( $_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $path)) {
echo "The file ". basename( $_FILES['file']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
}
?>
@amriunix
Copy link
Author

Powershell UPLOAD Script

$uri = "http://127.0.0.1/upload.php"
$filepath="/tmp/file_to_upload.zip"
$wc = New-Object System.Net.WebClient
$resp = $wc.UploadFile($uri,$filepath)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment