/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $sheet = new CreateExcelSheet(); $fileName = $sheet->createSheetFromTemp($request); Flash::success('messages.success.created'); return Response::download(storage_path('invoices' . '/' . $fileName . '.xls')); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Requests\CreateQuotation $request) { $newQuotation = new CreateDocument(); $request->merge(['ref' => Carbon::now()->format('y-m-d')]); $fileName = $newQuotation->CreateFromTemp($request); Flash::success('messages.success.created'); return Response::download(storage_path('quotations' . '/' . $fileName . '.docx')); }
public function exportDB() { Artisan::call('db:backup', ['--database' => 'mysql', '--destination' => 'local', '--destinationPath' => '\\dbBck\\sqlBck', '--compression' => 'null']); $file = storage_path('app') . "/dbBck/sqlBck"; //$fileName = Crypt::encrypt(rand(11111,99999)).'DB_Backup.sql'; $fileName = uniqid(Carbon::now() . 'DB_Backup') . '.sql'; $headers = array('Content-Type: application/sql'); return Response::download($file, $fileName, $headers)->deleteFileAfterSend(true); }
public function getPicture($user) { if ($user->profile && $user->profile->picture) { return Response::download(storage_path('app/' . $user->profile->picture->filePath())); } if ($user->facebookUser) { return Response::make(file_get_contents('https://graph.facebook.com/' . $user->facebookUser->id . '/picture?type=large'))->header('Content-Type', 'image/jpeg'); } return Response::download(storage_path('app/no_image.jpg')); }
public function index() { if (Input::get('l')) { LaravelLogViewer::setFile(base64_decode(Input::get('l'))); } if (Input::get('dl')) { return Response::download(storage_path() . '/logs/' . base64_decode(Input::get('dl'))); } $logs = LaravelLogViewer::all(); return View::make('laravel-log-viewer::log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]); }
public function export() { $slug = Input::get('slug'); $fields = Input::get('fields', []); $models = Config::get('dashboard::models'); if (!array_key_exists($slug, $models)) { throw new NotFoundHttpException('Model not found'); } $model = $models[$slug]; $data = $model['model']::select($fields)->get()->toArray(); $path = Backup::csv("dashboard_{$slug}", $data, $fields); return Response::download($path); }
/** * Show the profile for the given user. * * @param Request $req * @return Response */ public function index() { $name = ''; if (isset($_POST)) { $Theme = new Theme($_POST); $name = $Theme->createTheme(); if (strlen($name) > 0) { $file = public_path() . '/' . $name; $headers = array('Content-Type: application/zip'); return Response::download($file, $name, $headers); } } return view('dashboard.index', ['data' => $name]); }
public function index() { if (Input::get('l')) { LaravelLogViewer::setFile(base64_decode(Input::get('l'))); } if (Input::get('dl')) { return Response::download(storage_path() . '/logs/' . base64_decode(Input::get('dl'))); } elseif (Input::has('del')) { File::delete(storage_path() . '/logs/' . base64_decode(Input::get('del'))); return Redirect::to(Request::url()); } $logs = LaravelLogViewer::all(); return View::make('log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]); }
/** * Returns a file in the assets directory * * @return \Illuminate\Support\Facades\Response */ public function file($path) { $file = Asset::getFullPath($path); if (Asset::isJavascript($path)) { return $this->javascript($path); } if (Asset::isStylesheet($path)) { return $this->stylesheet($path); } if (file_exists($file)) { return Response::download($file); } App::abort(404); }
public function archive($owner, $project, $format, $branch) { $repository = $project->getRepository(); $tree = $repository->getBranchTree($branch); if (false === $tree) { throw new HttpException(401); } $file = config('gitamin.cache_archives') . DIRECTORY_SEPARATOR . $project . DIRECTORY_SEPARATOR . substr($tree, 0, 2) . DIRECTORY_SEPARATOR . substr($tree, 2) . '.' . $format; if (!file_exists($file)) { $repository->createArchive($tree, $file, $format); } $filename = strtolower($project . '_' . $branch); $filename = preg_replace('#[^a-z0-9]+#', '_', $filename); $filename = $filename . '.' . $format; return Response::download($file, $filename); }
public function index() { if (Request::input('l')) { LaravelLogViewer::setFile(base64_decode(Request::input('l'))); } if (Request::input('dl')) { Log::notice('perm.log.site.download - SiteLog downloaded', ['user_id' => Request::user()->user_id]); return Response::download(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('dl')))); } elseif (Request::has('del')) { File::delete(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('del')))); Log::notice('perm.log.site.delete - SiteLog deleted', ['user_id' => Request::user()->user_id]); return Redirect::to(Request::url()); } $logs = LaravelLogViewer::all(); Log::notice('perm.log.site.view - SiteLog opened', ['user_id' => Request::user()->user_id]); return View::make('laravel-log-viewer::log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]); }
public function download() { $assets = AssetFacade::find($this->request->input('assets')); if (count($assets) === 1) { return Response::download($assets[0]->getFilename(), $assets[0]->getOriginalFilename()); } $downloadFilename = rtrim($this->request->input('filename'), '.zip') . '.zip'; $filename = tempnam(sys_get_temp_dir(), 'boomcms_asset_download'); $zip = new ZipArchive(); $zip->open($filename, ZipArchive::CREATE); foreach ($assets as $asset) { $zip->addFile($asset->getFilename(), $asset->getOriginalFilename()); } $zip->close(); $response = Response::make()->header('Content-type', 'application/zip')->header('Content-Disposition', "attachment; filename={$downloadFilename}")->setContent(file_get_contents($filename)); unlink($filename); return $response; }
public function getIndex() { AssetManager::addScript('admin::default/js/datatables/jquery.dataTables.min.js'); AssetManager::addScript('admin::default/js/datatables/jquery.dataTables_bootstrap.js'); AssetManager::addScript('admin::default/js/notify-combined.min.js'); AssetManager::addStyle('admin::default/css/dataTables.bootstrap.css'); if (Input::get('l')) { LaravelLogViewer::setFile(base64_decode(Input::get('l'))); } if (Input::get('dl')) { return Response::download(storage_path() . '/logs/' . base64_decode(Input::get('dl'))); } elseif (Input::has('del')) { File::delete(storage_path() . '/logs/' . base64_decode(Input::get('del'))); return Redirect::to(Request::url()); } $logs = LaravelLogViewer::all(); $view = View::make('an-admin::page.log-viewer', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]); return Admin::view($view, trans('an-admin::lang.log-viewer.title')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($mcid_id) { $headers = array('Cache-Control' => 'no-cache, no-store, max-age=0, must-revalidate', 'Pragma' => 'no-cache', 'Expires' => 'Fri, 01 Jan 1990 00:00:00 GMT'); $mcid_id = str_replace('.png', '', $mcid_id); // dd($mcid_id); $mcid = MCID::where('mcid', $mcid_id)->first(); if ($mcid != null && !$mcid->genuine) { $file = $this->manager->fileDetails($mcid->skin->url); return Response::download(public_path() . config('site.uploads.webpath') . $file['fullPath'], null, $headers)->setContentDisposition('inline'); } else { $skin = $this->get_skin($mcid_id); $im = imagecreatefromstring($skin); //ブレンドモードを無効にする imagealphablending($im, false); imagesavealpha($im, true); // start buffering ob_start(); imagepng($im); imagedestroy($im); $contents = ob_get_contents(); ob_end_clean(); return Response::make($contents, 200, $headers)->header('Content-Type', 'image/png'); } }
private function utilStreamFile($headers, $filePath) { if (!file_exists($filePath)) { return false; } $mimeType = $this->getMimeType($filePath); // Set the appropriate mime type $headers['Content-Type'] = $mimeType; // Make sure this is not cached $headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'; $headers['Pragma'] = 'no-cache'; $headers['Expires'] = 0; return Response::download($filePath); }
public function getGetfilebyid(Request $request) { $this->validate($request, ['id' => 'required'], [], ['id' => '文件ID']); if ($request->has('id')) { $id = $request->get('id'); $file = File::find($id); $file->download_count = $file->download_count + 1; $file->save(); $path = $file->path; $filename = $file->filename . $file->extension; $finfo = finfo_open(FILEINFO_MIME); $type = finfo_file($finfo, storage_path() . '/app/' . $path); finfo_close($finfo); $headers = array('Content-Type: ' . $type); return Response::download(storage_path() . '/app/' . $path, $filename, $headers); } else { return; } }
/** * download activity template as 'iati_activity_template2.csv' * @return mixed */ public function downloadActivityTemplate2() { $pathToFile = app_path("Core/" . session()->get('version') . "/Files/Csv/iati_activity_template2.csv"); if (!File::exists($pathToFile)) { $pathToFile = app_path("Core/" . config('app.default_version_name') . "/Files/Csv/iati_activity_template2.csv"); } return Response::download($pathToFile); }
public function download($id) { $file = Files::findOrFail($id); return Response::download(storage_path() . '/upload/' . $file->filename); }
public function download($bajar) { //descargar documento seleccionado $file = productos::descargar($bajar); return Response::download($file); }
/** * Download a file * * @return mixed */ public function getDownload() { $file_to_download = Input::get('file'); $dir = Input::get('dir'); return Response::download(base_path() . "/" . $this->file_location . $dir . "/" . $file_to_download); }
/** * Download a file * * @return mixed */ public function getDownload() { $file_to_download = Input::get('file'); $dir = Input::get('dir'); return Response::download(base_path() . "/" . Config::get('sfm.dir') . $dir . "/" . $file_to_download); }
/** * 下载文件 * @param Request $request * @return mixed */ public function download(Request $request) { $filename = $request->get('filename'); if (!$filename) { abort(404); } $path = storage_path('download') . '/' . $filename; if (!file_exists($path)) { abort(404); } return Response::download($path); }
/** * Retorna o arquivo csv da consulta * @param Request $request */ public function download(Request $request) { $agrupamento = $request['agrupamento']; $uf = $request['uf']; $cidade = $request['cidade']; $tipo = $request['tipo']; if (isset($request['ativo'])) { switch ($request['ativo']) { case 1: $ativo = [1]; break; case 2: $ativo = [0]; break; case 3: $ativo = [1, 0]; break; } } else { $ativo = [1]; } if (isset($request['localizacao'])) { switch ($request['localizacao']) { case 1: /*Área Urbana*/ $localizacao = [1]; break; case 2: /*Áre não urbana*/ $localizacao = [2]; break; case 3: /*Todas*/ $localizacao = [0, 1, 2]; break; } } else { $localizacao = [1, 2]; } if ($agrupamento == 0 || $uf != 0) { if ($uf != 0) { if ($cidade != '') { /*busca pid/iniciativa de uma cidade*/ $dados = $this->getFullDadosByCidade($cidade, $tipo, $ativo, $localizacao); } else { /*busca pid/iniciativa de um estado*/ $dados = $this->getFullDadosByUf([$uf], $tipo, $ativo, $localizacao); } } else { /*busca todos os pid/iniciativa*/ $dados = $this->getFullDados($tipo, $ativo, $localizacao); } } else { switch ($agrupamento) { case '1': /*Centro Oeste*/ $dados = $this->getFullDadosByUf([50, 51, 52, 53], $tipo, $ativo, $localizacao); break; case '2': /*Norte*/ $dados = $this->getFullDadosByUf([11, 12, 13, 14, 15, 16, 17], $tipo, $ativo, $localizacao); break; case '3': /*Nordeste*/ $dados = $this->getFullDadosByUf([21, 22, 23, 24, 25, 26, 27, 28, 29], $tipo, $ativo, $localizacao); break; case '4': /*Sul*/ $dados = $this->getFullDadosByUf([41, 42, 43], $tipo, $ativo, $localizacao); break; case '5': /*Suldeste*/ $dados = $this->getFullDadosByUf([31, 32, 33, 35], $tipo, $ativo, $localizacao); break; } } /*Converte os dados de pids de stdClass para Array*/ $pids = []; foreach ($dados['pids'] as &$dados['pids']) { $pids[] = (array) $dados['pids']; } /*Converte os dados de iniciativas de stdClass para Array*/ $iniciativas = []; foreach ($dados['iniciativas'] as &$dados['iniciativas']) { $iniciativas[] = (array) $dados['iniciativas']; } $id = Carbon::now()->format('dmYhis'); $pathPid = storage_path() . '/consultas/pids' . $id . '.csv'; $pathIniciativa = storage_path() . '/consultas/iniciativas' . $id . '.csv'; $handle = fopen($pathPid, 'w+'); fputcsv($handle, array('id', 'nome', 'email', 'url', 'tipo_id', 'destaque', 'ativo', 'updated_at', 'nomeCidade', 'uf', 'logradouro', 'numero', 'latitude', 'longitude')); foreach ($pids as $row) { fputcsv($handle, array($row['id'], $row['nome'], $row['email'], $row['url'], $row['tipo_id'], $row['destaque'], $row['ativo'], $row['updated_at'], $row['nomeCidade'], $row['uf'], $row['logradouro'], $row['numero'], $row['latitude'], $row['longitude'])); } fclose($handle); $handle = fopen($pathIniciativa, 'w+'); fputcsv($handle, array('id', 'tipo_id', 'nome', 'sigla', 'email', 'url', 'objetivo', 'informacaoComplementar', 'categoria_id', 'fonte', 'nomeCidade', 'uf', 'logradouro', 'numero', 'latitude', 'longitude')); foreach ($iniciativas as $row) { fputcsv($handle, array($row['id'], $row['tipo_id'], $row['nome'], $row['sigla'], $row['email'], $row['url'], $row['objetivo'], $row['informacaoComplementar'], $row['categoria_id'], $row['fonte'], $row['nomeCidade'], $row['uf'], $row['logradouro'], $row['numero'], $row['latitude'], $row['longitude'])); } fclose($handle); $zipPath = storage_path() . '/consultas/consulta' . $id . '.zip'; $zip = new ZipArchive(); $zip->open($zipPath, ZipArchive::CREATE); $zip->addFile($pathPid, 'Pids.csv'); $zip->addFile($pathIniciativa, 'Iniciativas.csv'); $zip->close(); unlink($pathPid); unlink($pathIniciativa); return Response::download($zipPath); }
public function downloadFile($folder, $serviceOrder, $file) { $finalPath = storage_path() . '/app/' . $folder . '/' . $serviceOrder . '/' . $file; return Response::download($finalPath); }
/** * The GET method that runs when a user needs to download a file * * @return JSON */ public function fileDownload() { if ($response = Session::get('administrator_download_response')) { Session::forget('administrator_download_response'); $filename = substr($response['headers']['content-disposition'][0], 22, -1); return Response::download($response['file'], $filename, $response['headers']); } else { return Redirect::back(); } }
public function download($file) { $fileName = pathinfo($file, PATHINFO_FILENAME); $array = explode('.', $file); $extension = end($array); $decodeFile = base64_decode($fileName) . '.' . $extension; $downloadUrl = storage_path() . '\\upload\\' . Session::get('index') . '\\' . $file; return Response::download($downloadUrl, $decodeFile); }
/** * Description: Download other documents * By: Dhara * @param type $id * @return type */ public function getDownload($id) { $record = \App\Modules\Blog\Models\PostUpload::find($id); $file = public_path() . '/../app/Modules/Blog/myupload' . '/' . $record->post_id . '/' . $record->media_name; //var_dump($file2);exit; $path_parts = pathinfo($file); $ext = strtolower($path_parts["extension"]); switch ($ext) { case "pdf": $headers = array("Content-type: application/pdf"); break; case "docx": $headers = array("Content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document"); break; // add more headers for other content types here // add more headers for other content types here default: $headers = array("Content-type: application/octet-stream"); break; } return Response::download($file, $record->media_name, $headers); }
function downloadAttachment($id) { $attachment = Attachment::find($id); if (empty($attachment)) { abort(404); } $filename = $attachment->filename; $file = public_path() . "/resources/uploads/attachments/" . $filename; $headers = array('Content-Type: application/pdf'); return Response::download($file); }
public function getDownload($packageVersionUuid) { $packageVersion = PackageVersion::where('package_version_uuid', '=', $packageVersionUuid)->first(); $packagePath = $packageVersion->package_path; // set download parameters // $filename = basename($packagePath); $headers = array('content-type: application/octet-stream'); // download and return file // return Response::download($packagePath, $filename, $headers); }
/** * Download a file * * @return mixed */ public function getDownload() { return Response::download(parent::getPath('directory') . Input::get('file')); }