diff --git a/docs/www/fileupload.php b/docs/www/fileupload.php new file mode 100644 index 0000000..09a09c7 --- /dev/null +++ b/docs/www/fileupload.php @@ -0,0 +1,50 @@ +permissions & 128)) { + header($_SERVER["SERVER_PROTOCOL"]." 403 Forbidden", true, 403); + include($_SERVER["DOCUMENT_ROOT"]."/errors/403.php"); + die(); +} + +display_header("Upload a file."); + +if(isset($_POST["submit"])) { + $uploadDir = '/srv/http/assets/upload/'; + $firstDir = bin2hex(random_bytes(16)); + $secondDir = bin2hex(random_bytes(16)); + $filename = bin2hex(random_bytes(16)); + $combinedPath = $firstDir."/".$secondDir."/".$filename; + + mkdir($uploadDir.$firstDir, 0774); + mkdir($uploadDir.$firstDir."/".$secondDir, 0774); + + echo "
";
+	if (move_uploaded_file($_FILES['userfile']['tmp_name'],
+		$uploadDir.$combinedPath)) {
+		echo "File is valid, and was successfully uploaded.\n";
+		printf("location: assets.zdenekborovec.cz/upload/%s", $combinedPath);
+	} else {
+		echo "File upload failed.\n";
+	}
+	echo "
"; +} + +?> + + +
"> + + + + +
+ +