From ed66392fc694ffb10b59a22b9305c7334d13a67f Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 12 Feb 2021 12:38:09 +0200 Subject: upload prototype. needs to be checked --- php/.database.php.swp | Bin 16384 -> 16384 bytes php/.upload.php.swp | Bin 0 -> 12288 bytes php/database.php | 21 +++++++++++++++++++++ php/upload.php | 23 +++++++++++------------ 4 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 php/.upload.php.swp (limited to 'php') diff --git a/php/.database.php.swp b/php/.database.php.swp index 5193729..eecacf9 100644 Binary files a/php/.database.php.swp and b/php/.database.php.swp differ diff --git a/php/.upload.php.swp b/php/.upload.php.swp new file mode 100644 index 0000000..e1fc62b Binary files /dev/null and b/php/.upload.php.swp differ diff --git a/php/database.php b/php/database.php index a46bdd2..cfef823 100644 --- a/php/database.php +++ b/php/database.php @@ -164,6 +164,27 @@ require_once "node.php"; //print count($id); return $id[0]; } + /*returns the file name as it must be in the filesystem*/ + function create_file_node(string $filename): string + { + global $storage_root; + $code=get_random_node_name(""); + if($filename==NULL)return false; + $prep=$this->pdo->prepare("insert into nodes(is_directory,relative_path,name,code) + values(false,:root,:name,:code) + "); + $prep->bindParam(':name',$filename); + $prep->bindParam(':root',$storage_root); + + $prep->bindParam(':code',$code); + if($prep->execute()==false) + { + error_log("could not upload file"); + /*not so quiet error*/ + return "error"; + } + return code; + } function are_linked(int $directory_id,int $node_id): bool { $prepare=$this->pdo->prepare("select node_id diff --git a/php/upload.php b/php/upload.php index d9110c7..bd72b6b 100644 --- a/php/upload.php +++ b/php/upload.php @@ -1,22 +1,21 @@ -- cgit v1.2.3