aboutsummaryrefslogtreecommitdiffstats
path: root/php/upload.php
diff options
context:
space:
mode:
authoradam <adam@>2021-02-15 14:36:23 +0200
committeradam <adam@>2021-02-15 14:36:23 +0200
commit7f67235a44f3241b18d1a9d3ebd991ef7f90c28f (patch)
treefd4ae594b47de5d56915db393d50fc8ea7b02ab7 /php/upload.php
parent79f0da7f94acd7a04088fee3653299806ff16eec (diff)
downloadfileup-7f67235a44f3241b18d1a9d3ebd991ef7f90c28f.tar.gz
hacks and contents
Diffstat (limited to 'php/upload.php')
-rw-r--r--php/upload.php12
1 files changed, 9 insertions, 3 deletions
diff --git a/php/upload.php b/php/upload.php
index 04f2214..94e30d1 100644
--- a/php/upload.php
+++ b/php/upload.php
@@ -6,7 +6,7 @@ require_once "user.php";
require_once "node.php";
session_start();
-if (!isset( $_POST["filename"]) || !isset($_FILES["the_file"]) || !isset($_POST['parent_directory']) || !isset($_POST['overwrite']))
+if (!isset( $_POST["filename"]) || (!isset($_FILES["the_file"]) && (!isset($_POST['content'] || gettype($_POST['content'])!="string"))|| !isset($_POST['parent_directory']) || !isset($_POST['overwrite']))
{
error_log("someone tried to upload something impropperly");
http_response_code(400);
@@ -41,8 +41,14 @@ if($codename=="filename taken")
http_response_code(409);
exit(0);
}
-unlink("$storage_root/$codename");
-move_uploaded_file($file['tmp_name'], "$storage_root/$codename");
+if(isset($_POST['content']))
+{
+ file_put_contents("$storage_root/$codename",$_POST['content']);
+}else
+{
+ unlink("$storage_root/$codename");
+ move_uploaded_file($file['tmp_name'], "$storage_root/$codename");
+}
http_response_code(200);
exit(0);