Exemplo n.º 1
0
 protected function download($path, $display_if_can = true)
 {
     $pos = strrpos($path, '/');
     $filename = substr($path, $pos + 1);
     if ($display_if_can && FileHelper::canShow($path)) {
         return Yii::$app->response->sendFile($path, $filename, ['inline' => true]);
     }
     return Yii::$app->response->sendFile($path, $filename);
 }
Exemplo n.º 2
0
 /**
  * Check if file can be displayed in browser
  * @return array
  */
 public function canShow()
 {
     return FileHelper::canShow($this->getPath());
 }