From 077cab20146bf7cb26c330465fbd56cc0e0ddada Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 12 Feb 2021 13:24:33 +0200 Subject: asdf --- php/upload.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'php/upload.php') diff --git a/php/upload.php b/php/upload.php index 42a8bf6..b6cd335 100644 --- a/php/upload.php +++ b/php/upload.php @@ -2,20 +2,26 @@ require_once "database.php"; require_once "configuration.php"; -if (!isset( $_POST["filename"]) || !isset($_POST["the_file"])) +if (!isset( $_POST["filename"]) || !isset($_FILES["the_file"])) { http_response_code(400); error_log("someone tried to upload something impropperly"); exit(1); } -$file = $_POST["the_file"]; +$file = $_FILES["the_file"]; $filename= $_POST["filename"]; -$codename=create_file_node($filename); - -copy($file['tmp_name'], "$storage_root/$codename"); +$codename=$database->create_file_node($filename); +if($codename=="error") +{ + http_response_code(400); + exit(0); +} +error_log($file['tmp_name']); +move_uploaded_file($file['tmp_name'], "$storage_root/$codename"); -echo $codename; +http_response_code(200); +exit(0); ?> -- cgit v1.2.3