aboutsummaryrefslogtreecommitdiffstats
path: root/php
diff options
context:
space:
mode:
authoradam <adam@>2021-02-12 19:54:52 +0200
committeradam <adam@>2021-02-12 19:54:52 +0200
commitaf0c31ec0ebbfabd3f6140b816752ccf96313225 (patch)
treeea9d230d03e82b485c588d424aced2862dbe587f /php
parentfd807f7df9ab0b3021e071eb0ff4be6e252938a8 (diff)
downloadfileup-af0c31ec0ebbfabd3f6140b816752ccf96313225.tar.gz
mimetype draft
Diffstat (limited to 'php')
-rw-r--r--php/database.php2
-rw-r--r--php/file_type_recogniser.php2
-rw-r--r--php/upload.php4
3 files changed, 5 insertions, 3 deletions
diff --git a/php/database.php b/php/database.php
index fb3d35d..f5efec7 100644
--- a/php/database.php
+++ b/php/database.php
@@ -306,7 +306,7 @@ require_once "node.php";
}
}
/*returns the file name as it must be in the filesystem relative to the storage root*/
- function create_file_node(string $filename,string $note,int $dir_id,User $user): string
+ function create_file_node(string $filename,string $note,int $dir_id,string $mimetype,User $user): string
{
global $storage_root;
/*checkout the directory*/
diff --git a/php/file_type_recogniser.php b/php/file_type_recogniser.php
index f160fb7..d8e1d25 100644
--- a/php/file_type_recogniser.php
+++ b/php/file_type_recogniser.php
@@ -2,7 +2,7 @@
function file_type($path_to_file) {
$file_type_database = new finfo(FILEINFO_SYMLINK|FILEINFO_MIME_TYPE);
- return $file_type_database->file($path_to_file);
+ return $file_type_database->file($path_to_file);
}
diff --git a/php/upload.php b/php/upload.php
index b22c3a8..ee5d1ae 100644
--- a/php/upload.php
+++ b/php/upload.php
@@ -1,6 +1,7 @@
<?php
require_once "database.php";
require_once "configuration.php";
+require_once "file_type_recogniser.php";
session_start();
if (!isset( $_POST["filename"]) || !isset($_FILES["the_file"]))
@@ -14,9 +15,10 @@ $file=$_FILES["the_file"];
$filename=$_POST["filename"];
$user=$_SESSION['user_object'];
$homedir=$user->home_directory;
+$mimetype=file_type($file['tmp_name']);
-$codename=$database->create_file_node($filename,"",$homedir,$user);
+$codename=$database->create_file_node($filename,"",$homedir,$mimetype,$user);
if($codename=="error")
{
error_log("could not create file_node in upload.php");