Example #1
0
 public function getAttachment($file_name, $dbname)
 {
     $conn = mysqli_connect($this->host, $this->user, $this->password, $dbname, $this->port) or die('Could not connect to the database server' . mysqli_connect_error());
     $result = mysqli_query($conn, $this->attachment_query . '"' . $file_name . '"') or die(mysqli_error($conn));
     $file = null;
     if (mysqli_num_rows($result) > 0) {
         while ($row = mysqli_fetch_assoc($result)) {
             $file = new File($row["file_name"], $row["long_file_name"], $row["mime_tag"], $row["extension"]);
             $file->setData($row["data"]);
         }
     }
     mysqli_close($conn);
     return $file;
 }
Example #2
0
 public function testSizeIsReturned()
 {
     $file = new File('file');
     $file->setData('1234567890');
     $this->assertEquals(10, $file->size());
 }