当前位置: 首页>>代码示例>>PHP>>正文


PHP SS_HTTPRequest::send_file方法代码示例

本文整理汇总了PHP中SS_HTTPRequest::send_file方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPRequest::send_file方法的具体用法?PHP SS_HTTPRequest::send_file怎么用?PHP SS_HTTPRequest::send_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SS_HTTPRequest的用法示例。


在下文中一共展示了SS_HTTPRequest::send_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: backup

 /**
  * @return SS_HTTPRequest
  */
 public function backup()
 {
     $name = 'assets_' . SS_DateTime::now()->Format('Y-m-d') . '.zip';
     $tmpName = TEMP_FOLDER . '/' . $name;
     $zip = new ZipArchive();
     if (!$zip->open($tmpName, ZipArchive::OVERWRITE)) {
         user_error('Asset Export Extension: Unable to read/write temporary zip archive', E_USER_ERROR);
         return;
     }
     $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(ASSETS_PATH, RecursiveDirectoryIterator::SKIP_DOTS));
     foreach ($files as $file) {
         $local = str_replace(ASSETS_PATH . '/', '', $file);
         $zip->addFile($file, $local);
     }
     if (!$zip->status == ZipArchive::ER_OK) {
         user_error('Asset Export Extension: ZipArchive returned an error other than OK', E_USER_ERROR);
         return;
     }
     $zip->close();
     if (ob_get_length()) {
         @ob_flush();
         @flush();
         @ob_end_flush();
     }
     @ob_start();
     $content = file_get_contents($tmpName);
     unlink($tmpName);
     return SS_HTTPRequest::send_file($content, $name);
 }
开发者ID:helpfulrobot,项目名称:stnvh-silverstripe-assetexport,代码行数:32,代码来源:AssetAdminExport.php

示例2: handleExport

 /**
  * Handle the export, for both the action button and the URL
  */
 public function handleExport($gridField, $request = null)
 {
     $now = Date("d-m-Y-H-i");
     $fileName = "export-{$now}.csv";
     if ($fileData = $this->generateExportFileData($gridField)) {
         return SS_HTTPRequest::send_file($fileData, $fileName, 'text/csv');
     }
 }
开发者ID:jareddreyer,项目名称:catalogue,代码行数:11,代码来源:GridFieldExportButton.php

示例3: handleExport

 /**
  * Handle the export, for both the action button and the URL
  */
 public function handleExport($gridField, $request = null)
 {
     $now = Date("d-m-Y-H-i");
     $modelClass = $gridField->getModelClass();
     $fileName = "export-{$modelClass}-{$now}.xlsx";
     if ($fileData = $this->generateExportFileData($gridField)) {
         return SS_HTTPRequest::send_file($fileData, $fileName, 'application/xslt+xml');
     }
 }
开发者ID:helpfulrobot,项目名称:hutlim-silverstripe-phpexcel,代码行数:12,代码来源:GridFieldExportToExcelButton.php

示例4: handleExport

 /**
  * Handle the export, for both the action button and the URL
  */
 public function handleExport($gridField, $request = null)
 {
     $now = date("d-m-Y-H-i");
     $title = str_replace(' ', '-', strtolower(singleton($gridField->getModelClass())->singular_name()));
     $fileName = "export-{$title}-{$now}.xls";
     if ($fileData = $this->generateExportFileData($gridField)) {
         return SS_HTTPRequest::send_file($fileData, $fileName, 'application/xls+xml');
     }
 }
开发者ID:hutlim,项目名称:silverstripe-phpexcel,代码行数:12,代码来源:GridFieldExportToExcelButton.php

示例5: reportpreview

 public function reportpreview($data, $form)
 {
     $data = $form->getData();
     $format = $data['PreviewFormat'];
     $result = $this->record->createReport($format);
     if ($result->content) {
         return $result->content;
     } else {
         return SS_HTTPRequest::send_file(file_get_contents($result->filename), "{$data['GeneratedReportTitle']}.{$format}");
     }
 }
开发者ID:helpfulrobot,项目名称:maldicore-advancedreports,代码行数:11,代码来源:AdvancedReportsAdminItemRequest.php

示例6: handleAction

 public function handleAction(GridField $gridField, $actionName, $arguments, $data)
 {
     if (isset($arguments['FileID'])) {
         $response = Controller::curr()->getResponse();
         $file = File::get()->byID($arguments['FileID']);
         $path = $file->getFullPath();
         $filename = $file->getFileName();
         return SS_HTTPRequest::send_file(file_get_contents($path), $filename);
     }
     Controller::curr()->getResponse()->setStatusCode(200, 'No File');
 }
开发者ID:lekoala,项目名称:silverstripe-form-extras,代码行数:11,代码来源:GridFieldDownloadButton.php

示例7: download

 /**
  * Sends download request to registered members
  * 
  * @param	object	GET 'filename' request 
  * @return	object	HTTP request
  */
 public function download(SS_HTTPRequest $request)
 {
     $filename = $request->param('Filename');
     if (Member::currentUserID() && $request->isGET() && !empty($filename)) {
         $file = DB::query("SELECT Filename FROM File  WHERE Name = '" . Convert::raw2sql($filename) . "'")->value();
         if (!empty($file) && Director::fileExists($file)) {
             $file_contents = file_get_contents(Director::getAbsFile($file));
             return SS_HTTPRequest::send_file($file_contents, $filename);
         }
     }
     return Security::permissionFailure($this);
 }
开发者ID:rixrix,项目名称:silverstripe-clickbank,代码行数:18,代码来源:ClickBankController.php

示例8: download

 /**
  * Controller action for downloading a Clean File.
  * It responds to urls matching the following pattern:
  * 
  * /download/ClassName/ID
  * 
  * like:
  * 
  * /download/CleanFile/1
  * /download/CleanImage/1
  *
  * @param $request
  * @return SS_HTTPRequest
  */
 function download($request)
 {
     $classname = Convert::raw2sql($request->latestParam('ID'));
     $id = Convert::raw2sql($request->latestParam('OtherID'));
     if (is_numeric($id) && $classname != '' && $id != '') {
         if ($file = DataObject::get_by_id($classname, $id)) {
             if ($file->AttachmentID != 0 && isset($file->AttachmentID)) {
                 return SS_HTTPRequest::send_file(file_get_contents($file->Attachment()->getFullPath()), $file->Attachment()->Name);
             }
         }
     }
     return $this->owner->redirect($this->owner->Link());
 }
开发者ID:helpfulrobot,项目名称:arillo-silverstripe-cleanutilities,代码行数:27,代码来源:DownloadExtension.php

示例9: ticketfile

 public function ticketfile()
 {
     if (!$this->HasTicketFile() || $this->registration->Status != 'Valid') {
         $this->httpError(404);
     }
     $generator = $this->registration->Time()->Event()->TicketGenerator;
     $generator = new $generator();
     $path = $generator->generateTicketFileFor($this->registration);
     $path = Director::getAbsFile($path);
     $name = $generator->getTicketFilenameFor($this->registration);
     $mime = $generator->getTicketMimeTypeFor($this->registration);
     if (!$path || !file_exists($path)) {
         $this->httpError(404, 'The ticket file could not be generated.');
     }
     return SS_HTTPRequest::send_file(file_get_contents($path), $name, $mime);
 }
开发者ID:helpfulrobot,项目名称:ajshort-silverstripe-eventmanagement,代码行数:16,代码来源:EventRegistrationDetailsController.php

示例10: run

 function run($request)
 {
     //reset time limit
     set_time_limit(1200);
     //file data
     $now = Date("d-m-Y-H-i");
     $fileName = "export-{$now}.csv";
     //data object variables
     $orderStatusSubmissionLog = EcommerceConfig::get("OrderStatusLog", "order_status_log_class_used_for_submitting_order");
     $fileData = "";
     $offset = 0;
     $count = 50;
     while ($orders = Order::get()->sort("\"Order\".\"ID\" ASC")->innerJoin("OrderStatusLog", "\"Order\".\"ID\" = \"OrderStatusLog\".\"OrderID\"")->innerJoin($orderStatusSubmissionLog, "\"{$orderStatusSubmissionLog}\".\"ID\" = \"OrderStatusLog\".\"ID\"")->leftJoin("Member", "\"Member\".\"ID\" = \"Order\".\"MemberID\"")->limit($count, $offset) && ($ordersCount = $orders->count())) {
         $offset = $offset + $count;
         foreach ($orders as $order) {
             if ($order->IsSubmitted()) {
                 $memberIsOK = false;
                 if (!$order->MemberID) {
                     $memberIsOK = true;
                 } elseif (!$order->Member()) {
                     $memberIsOK = true;
                 } elseif ($member = $order->Member()) {
                     $memberIsOK = true;
                     if ($member->IsShopAdmin()) {
                         $memberIsOK = false;
                     }
                 }
                 if ($memberIsOK) {
                     $items = OrderItem::get()->filter(array("OrderID" => $order->ID));
                     if ($items && $items->count()) {
                         $fileData .= $this->generateExportFileData($order->getOrderEmail(), $order->SubmissionLog()->Created, $items);
                     }
                 }
             }
         }
         unset($orders);
     }
     if ($fileData) {
         SS_HTTPRequest::send_file($fileData, $fileName, "text/csv");
     } else {
         user_error("No records found", E_USER_ERROR);
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:43,代码来源:EcommerceTaskExportAllOrderItems.php

示例11: downloadExport

 public function downloadExport($gridField, $request = null)
 {
     $id = $request->param('ID');
     $job = ExportQueue::get()->filter('Signature', $id)->first();
     if ((int) $job->MemberID !== (int) Member::currentUserID()) {
         return Security::permissionFailure();
     }
     $now = Date("d-m-Y-H-i");
     $servedName = "export-{$now}.csv";
     $path = $this->getExportPath($id);
     $content = file_get_contents($path);
     unlink($path);
     rmdir(dirname($path));
     $response = SS_HTTPRequest::send_file($content, $servedName, 'text/csv');
     $response->addHeader('Set-Cookie', 'downloaded_' . $id . '=true; Path=/');
     $job->AddAction('Downloaded');
     return $response;
 }
开发者ID:botzkobg,项目名称:silverstripe-importexport,代码行数:18,代码来源:GridFieldExporter.php

示例12: download

 /**
  * Allows the user to download a file without right-clicking
  */
 function download()
 {
     if (isset($this->urlParams['ID'])) {
         $SQL_ID = Convert::raw2sql($this->urlParams['ID']);
         if (is_numeric($SQL_ID)) {
             $file = DataObject::get_by_id("Post_Attachment", $SQL_ID);
             $response = SS_HTTPRequest::send_file(file_get_contents($file->getFullPath()), $file->Name);
             $response->output();
         }
     }
     return Director::redirectBack();
 }
开发者ID:RyeDesigns,项目名称:silverstripe-forum,代码行数:15,代码来源:Post.php

示例13: downloadHeatmap

 public function downloadHeatmap($request)
 {
     $imageId = $request->param('ID');
     $image = File::get()->byID($imageId);
     return SS_HTTPRequest::send_file(file_get_contents(Director::absoluteBaseURL() . $image->Filename), $image->Name);
 }
开发者ID:hemant-chakka,项目名称:awss,代码行数:6,代码来源:ManageHeatmaps.php

示例14: exportastarball

 public function exportastarball()
 {
     $template = $this->getCurrentDynamicTemplate();
     if (!$template) {
         FormResponse::status_message("No template selected, Please select template");
         FormResponse::load_form($this->getitem(), 'Form_EditForm');
         return FormResponse::respond();
     } else {
         $fileData = $template->exportAs("tar.gz");
         $fileName = $template->Name . ".tar.gz";
         return SS_HTTPRequest::send_file($fileData, $fileName, "application/x-tar");
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-dynamictemplate,代码行数:13,代码来源:DynamicTemplateAdmin.php

示例15: export

 public function export()
 {
     if (isset($_REQUEST['baseurl'])) {
         $base = $_REQUEST['baseurl'];
         if (substr($base, -1) != '/') {
             $base .= '/';
         }
         Config::inst()->update('Director', 'alternate_base_url', $base);
     } else {
         $base = Director::baseURL();
     }
     $folder = TEMP_FOLDER . '/static-export';
     $project = project();
     $exported = $this->doExport($base, $folder . '/' . $project, false);
     `cd {$folder}; tar -czhf {$project}-export.tar.gz {$project}`;
     $archiveContent = file_get_contents("{$folder}/{$project}-export.tar.gz");
     // return as download to the client
     $response = SS_HTTPRequest::send_file($archiveContent, "{$project}-export.tar.gz", 'application/x-tar-gz');
     echo $response->output();
 }
开发者ID:helpfulrobot,项目名称:silverstripe-staticpublisher,代码行数:20,代码来源:StaticExporter.php


注:本文中的SS_HTTPRequest::send_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。