aboutsummaryrefslogtreecommitdiffstats
path: root/php/upload.php
diff options
context:
space:
mode:
Diffstat (limited to 'php/upload.php')
-rw-r--r--php/upload.php18
1 files changed, 12 insertions, 6 deletions
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);
?>