F diff --git a/php/database.php b/php/database.php --- a/php/database.php +++ b/php/database.php}/*if both are not null returns the id of the node with the name name in the directory_id node*/- function get_node_id($name,$directory_id)+ function get_node_id(string $name,int $directory_id){- $statement=$this->pdo->prepare(- "select nl.node_id as id from node_links nl- inner join nodes n on n.node_id=nl.node_id- where name=:name and directory_id=:directory_id)");+ $statement=$this->pdo->prepare("+ select node_links.node_id as id+ from node_links+ inner join nodes on+ nodes.node_id=node_links.node_id+ where node_links.name=:name and node_links.directory_id=:directory_id+ ");$statement->bindParam(':name',$name);$statement->bindParam(':directory_id',$directory_id);if($statement->execute()==false)return NULL;}$hold=$statement->fetch(PDO::FETCH_ASSOC);- if($hold==false)+ if(gettype($hold)!="array"){return NULL;}elsereturn "error";}+ /*check if node with given name exists*/+ if($this->get_node_id($filename,$dir_id)!=NULL)+ {+ error_log("filename taken");+ return "filename taken";+ }/*generate the node*/$code=$this->get_random_node_name("");if($filename==NULL)return "error";F diff --git a/php/upload.php b/php/upload.php --- a/php/upload.php +++ b/php/upload.phphttp_response_code(400);exit(0);}+ if($codename=="filename taken")+ {+ http_response_code(409);+ exit(0);+ }move_uploaded_file($file['tmp_name'], "$storage_root/$codename");http_response_code(200);