diff options
author | Alex Vitkov <alexvitkov98@gmail.com> | 2021-02-12 20:07:10 +0200 |
---|---|---|
committer | Alex Vitkov <alexvitkov98@gmail.com> | 2021-02-12 20:07:10 +0200 |
commit | d66cf65a66b2eac4b9ccaf47dc7c0e9577687b3f (patch) | |
tree | a35e5ce475ae029dbed3e8178182caa22ae25d5f /php | |
parent | eecdb71a05c4e6ee255e097bf93df37a1efb751f (diff) | |
parent | 369de870ef6dbcd67ac9316bf714a6ded892eadc (diff) | |
download | fileup-d66cf65a66b2eac4b9ccaf47dc7c0e9577687b3f.tar.gz |
Merge branch 'master' of https://github.com/alexvitkov/india
Diffstat (limited to 'php')
-rw-r--r-- | php/database.php | 7 | ||||
-rw-r--r-- | php/file_type_recogniser.php | 2 | ||||
-rw-r--r-- | php/upload.php | 4 |
3 files changed, 8 insertions, 5 deletions
diff --git a/php/database.php b/php/database.php index fb3d35d..789ea86 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*/ @@ -347,11 +347,12 @@ require_once "node.php"; /*generate the node*/ $code=$this->get_random_node_name(""); if($filename==NULL)return "error"; - $prep=$this->pdo->prepare("insert into nodes(is_directory,relative_path,code) - values(false,:root,:code) + $prep=$this->pdo->prepare("insert into nodes(is_directory,relative_path,code,type) + values(false,:root,:code,:type) "); $prep->bindParam(':root',$code); $prep->bindParam(':code',$code); + $prep->bindParam(':type',$mimetype); if($prep->execute()==false) { 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"); |