Hi, @youtuber! I found several issues on your code...
Your first PHP code requires a file input named "file"; your second PHP code requires "datei", whereas your AutoIt script gives a file input named "uploadinput"
Your second PHP code requires a post variable named "filename", whereas your AutoIt script gives it named "str"
Your second PHP code requries a post variable named "password" to be "Pass123", whereas your AutoIt script doesn't give it.
Both the PHP codes are vulnerable, as anyone can upload malicious PHP files onto it.
Here's a short example (warning: I didn't test it):
_HTTP_Upload("http://test/postscript.php", "myFile.txt", "uploadinput", "pwd=123&filename=" & URLEncode("test.txt") )
<?php
define('PASSWORD', '123'); // put pwd here
$pwd = isset($_REQUEST['pwd']) ? $_REQUEST['pwd'] : null;
if ($pwd!=PASSWORD) {
header("HTTP/1.0 403 Forbidden");
echo "403 Forbidden";
exit;
}
$allowed_extensions = ['txt', 'doc', 'docx']; // set it
if ($_FILES['uploadinput']['tmp_name']) {
$file_extension = strtolower(end($tmp = explode(".", $_POST['filename']))); // $tmp to avoid "should be passed as ref" notice
if(in_array($file_extension, $allowed_extensions)) {
move_uploaded_file($_FILES['uploadinput']['tmp_name'], 'uploads/'.$_POST['filename']);
}
}
echo 'ok';