aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradam <adam@>2021-02-15 14:46:48 +0200
committeradam <adam@>2021-02-15 14:46:48 +0200
commit7532e744e0be43657cafffce171f875ffe94fc3f (patch)
tree62e7bdfc765fd73db9b92469f45597cd369f754f
parent65aa6e963f8508ad1e95462ceebf52c9f8209f67 (diff)
downloadfileup-7532e744e0be43657cafffce171f875ffe94fc3f.tar.gz
mimetype problems
-rw-r--r--php/upload.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/php/upload.php b/php/upload.php
index 94e30d1..f3ef550 100644
--- a/php/upload.php
+++ b/php/upload.php
@@ -6,7 +6,9 @@ require_once "user.php";
require_once "node.php";
session_start();
-if (!isset( $_POST["filename"]) || (!isset($_FILES["the_file"]) && (!isset($_POST['content'] || gettype($_POST['content'])!="string"))|| !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);
@@ -18,10 +20,17 @@ $filename=$_POST["filename"];
$parent_directory=$_POST["parent_directory"];
$user=$_SESSION['user_object'];
$homedir=$user->home_directory;
-$mimetype=file_type($file['tmp_name']);
$overwrite=$_POST['overwrite'];
$dir = get_directory($parent_directory, $user);
+
+if(isset($_POST['content']))
+{
+ $mimetype="text/plain";
+}else
+{
+ $mimetype=file_type($file['tmp_name']);
+}
if (!$dir)
{
error_log("trying to upload to invalid directory");