Esempio n. 1
0
 public function getPathToFile(\Filehosting\File $file, $relative = false)
 {
     $fileName = $file->getId() . $file->getFileName();
     if ($relative == true) {
         return "/../files/" . $fileName;
     }
     return $this->root . "/../files/" . $fileName;
 }
Esempio n. 2
0
 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;
 }