public function addFile(\Filehosting\File $file) { $sth = $this->dbh->prepare("INSERT INTO files(filename, size, upload_time, comment, token, original_name)\n VALUES(:filename, :size, :upload_time, :comment, :token, :original_name)"); $sth->bindValue(":filename", $file->getFileName()); $sth->bindValue(":size", $file->getSize()); $sth->bindValue(":upload_time", date("Y-m-d H:i:s", $file->getUploadTime())); $sth->bindValue(":comment", $file->getComment()); $sth->bindValue(":token", $file->getToken()); $sth->bindValue(":original_name", $file->getOriginalName()); $sth->execute(); $id = $this->dbh->lastInsertId(); return $id; }
public function getDownloadPath(\Filehosting\File $file) { $fileName = $file->getOriginalName(); $id = $file->getId(); return "/download/" . $id . "/" . $fileName; }