Ejemplo n.º 1
0
 /**
  * Index method to serve a file
  *
  * @return null
  */
 public function action_index($photo = NULL)
 {
     $photo = new Model_Vendo_Photo($photo);
     if (!$photo->id) {
         throw new Vendo_404('Photo not found');
     }
     $path_info = pathinfo($photo->path() . $photo->filename);
     $ext = $path_info['extension'];
     header('Content-Type: image/' . $path_info['extension']);
     header('Content-Length: ' . filesize($photo->path() . $photo->filename));
     readfile($photo->path() . $photo->filename);
     die;
 }
Ejemplo n.º 2
0
Archivo: photo.php Proyecto: vendo/core
 /**
  * Tests that we can process and read and delete a photo
  * 
  * @return null
  */
 public function test_do_it()
 {
     $photo = new Model_Vendo_Photo();
     $photo->file = DOCROOT . 'media/images/grid.png';
     $photo->save();
     $path = $photo->path() . $photo->filename;
     $this->assertFalse($photo->id === NULL);
     $this->assertTrue(file_exists($path));
     $photo->delete();
     $this->assertFalse(file_exists($path));
 }