Esempio n. 1
0
 public function viewfilecongvandibyuser($filename)
 {
     $user = Auth::user();
     $is_download = File::downloadcongvandibyusername($filename, $user);
     if ($is_download) {
         $file = storage_path() . '/uploads/' . $filename;
         $response = \Response::make($file, 200);
         $content_types = ['application/octet-stream', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/pdf'];
         // using this will allow you to do some checks on it (if pdf/docx/doc/xls/xlsx)
         $response->header('Content-Type', $content_types);
         return $response;
     } else {
         return \Redirect::to('/')->with('error', 'Không có quyền truy cập');
     }
 }