本文整理汇总了PHP中Response::download方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::download方法的具体用法?PHP Response::download怎么用?PHP Response::download使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response::download方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDownload
public function getDownload()
{
//PDF file is stored under project/public/download/info.pdf
$file = public_path() . "/download/info.pdf";
$headers = array('Content-Type: resume/docx');
return Response::download($file, 'alexandra_gutierrez_resume.pdf', $headers);
}
示例2: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$filename = $this->argument('set') . "set.arff";
$handle = fopen($filename, 'w+');
$text = "@relation 'price'\n@attribute y {-1,1}\n@attribute x0 numeric\n@attribute x1 numeric\n@attribute x3 numeric\n@attribute x4 numeric\n@attribute x5 numeric\n@attribute x6 numeric\n@attribute x7 numeric\n@attribute x8 numeric\n@attribute x9 numeric\n@data\n\n";
$set = \MkmScraper\Set::find($this->argument('set'));
$array = array(array());
foreach ($set->mythics as $card) {
foreach ($card->graphPrices as $key => $price) {
$row = array();
$row[] = $price->priceClass();
$row[] = $price->card->set->daysFromReleaseDate($price->date);
$row[] = $price->card->set->daysFromRotationDate($price->date);
$row[] = $price->tournamentDiffWeek();
$row[] = $price->tournamentDiffTwoWeek();
$row[] = $price->articlesDiffLastWeek();
$row[] = $price->articlesDiffLastTwoWeek();
$row[] = $price->otherCardMovementDay();
$row[] = $price->otherCardMovementWeek();
$row[] = $price->boostersOpen();
$array[] = $row;
}
}
foreach ($array as $row) {
foreach ($row as $item) {
$text .= $item . ",";
}
$text .= "\n";
}
file_put_contents($filename, $text);
return \Response::download($this->argument('set') . 'set.arff', $this->argument('set') . 'set.arff', array('Content-Type' => 'text/aarf'));
}
示例3: store
/**
* Store a newly created resource in storage.
* POST /policies
*
* @return Response
*/
public function store($id)
{
//
$download = AdminPolicies::where('download_id', $id)->first();
$destinationPath = storage_path('download_files/' . $download->pdffile);
return Response::download($destinationPath);
}
示例4: getDownload
public function getDownload()
{
//to prevent users from downloading posters created by other people we get the folder hash from the session.
$hash = Session::get('hash');
$destinationPath = 'uploads/' . $hash;
return Response::download($destinationPath . '/poster.jpg');
}
示例5: exportCustomerData
public function exportCustomerData()
{
$customers = CustomerData::orderBy('id')->get();
$customers = $customers->toArray();
$filename = CustomerData::exportData($customers);
return Response::download(public_path($filename));
}
示例6: download
protected function download(Path $path)
{
// check basic auth headers as well, so if specified,
// client doesn't have to go through the login and cookie dance.
Auth::onceBasic("username");
// check we're logged in
if (!Auth::check()) {
Session::flash('redirect', URL::current());
return Redirect::route('login');
}
// record the download in the db
$record = $path->loadCreateRecord($path);
$record->downloaded_at = $record->freshTimestamp();
$record->increment('downloads');
$record->save();
$isMisc = strpos($path->getRelative(), '/Misc/') === 0;
if ($isMisc || $path->isSafeExtension()) {
// check if the extension is safe to download
$file = new AsciiSafeDownloadFile($path->getPathname());
// see comments in AsciiSafeDownloadFile class
$baseName = $path->getBasename();
$baseName = str_replace('%', '', $baseName);
try {
return Response::download($file, $baseName);
} catch (InvalidArgumentException $e) {
App::abort(500, 'This file has a malformed filename. Please contact an admin.');
}
} else {
App::abort(403, sprintf('File type "%s" not allowed', $path->getExtension()));
}
}
示例7: create
public function create($type = 'csv')
{
try {
$export = static::getExportForType($type);
} catch (Exception $e) {
App::abort(404);
}
$export->user_id = Auth::user()->id;
$export->filename = $export->generateFilename();
$export->path = $export->folderPath();
$export->setLogbooks(Input::get('logbooks'));
$save = Input::has('save') ? (bool) Input::get('save') : true;
if ($export->run($save)) {
if ($save == false) {
$res = Response::make($export->content);
$res->header('Content-type', $export->getContentType());
return $res;
} else {
$export->save();
return Response::download($export->fullPath(), $export->filename, ['Content-type' => $export->getContentType()]);
}
} else {
return Redirect::to(action('ExportsController@index'))->with('message', ['content' => 'Er is iets mis gegaan met exporteren.', 'class' => 'danger']);
}
}
示例8: downloadFile
public static function downloadFile($id)
{
$record = self::find($id);
if (!$record) {
return \Response::json(['success' => false, 'message' => 'No record ...']);
}
return \Response::download($record->file_url, basename($record->file_name), []);
}
示例9: downloadingLocalOrCloudFiles
protected function downloadingLocalOrCloudFiles($fname)
{
if (!config('veer.use_cloud_files')) {
return \Response::download(storage_path() . '/app/' . config('veer.downloads_path') . "/" . $fname);
} else {
return redirect(config('veer.cloudstorage_path') . '/' . config('veer.downloads_path') . '/' . $fname);
}
}
示例10: download_file
/**
* Download file
*
* @return Response
*/
public function download_file($filename)
{
$file = public_path() . "/uploads/{$filename}";
if (File::isFile($file)) {
$headers = array('Content-Type: application/pdf', 'application/octet-stream', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/pdf');
return Response::download($file, $filename, $headers);
}
}
示例11: profilepicture
/**
* Show artist profile picture
*
* @return Response
*/
public function profilepicture($id, $type)
{
$pic = Picture::find($id);
if ($pic) {
return Response::download(storage_path() . "/pictures/" . $pic->name . "-" . $type . $pic->extension);
} else {
return Response::download(storage_path() . "/no-user.png");
}
}
示例12: picture
/**
* Show hub picture
*
* @return Response
*/
public function picture($id)
{
$pic = Picture::find($id);
if ($pic) {
return Response::download(storage_path() . "/pictures/" . $pic->name . ".png");
} else {
return App::abort(404);
}
}
示例13: getFileBinToShowById
public function getFileBinToShowById($id)
{
/** @var FileModel $file */
$file = FileModel::where('id', $id)->first();
if (!$file || !$file->baseFile) {
throw new NotFoundException(NotFoundException::FileNotFound);
}
return \Response::download($file->baseFile->getLocalCachePath(), [], 'inline');
}
示例14: getfile
public function getfile($filename)
{
$myfile = storage_path() . '/uploads/traces/' . $filename;
if (!\File::exists($myfile)) {
echo "File not exists.";
} else {
return \Response::download($myfile, $filename);
}
}
示例15: do_download
public function do_download($file)
{
//return Str::random(100);
if (Auth::check()) {
// return Redirect::to('https://www.sugarsync.com/pf/D9604663_69636075_6847618?directDownload=true');
$pathToFile = '/Users/myalienvirus/Sites/downloads/public/downloads/';
return Response::download($pathToFile . 'office11.Mac.iso');
}
return Redirect::to('/');
}