當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FileHelper::forceDownload方法代碼示例

本文整理匯總了PHP中FileHelper::forceDownload方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileHelper::forceDownload方法的具體用法?PHP FileHelper::forceDownload怎麽用?PHP FileHelper::forceDownload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FileHelper的用法示例。


在下文中一共展示了FileHelper::forceDownload方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: forceDownload

 public static function forceDownload($model, $name_field)
 {
     $src = '';
     $className = get_class($model);
     if ($className == 'ProListingUploadCea') {
         if (empty($model->{$name_field})) {
             throw new Exception("Invalid request. No {$name_field} found.");
         }
         $fileName = $model->{$name_field};
         $src = "upload/listing/" . $model->listing_id . "/cea/" . $fileName;
     } elseif ($className == 'ProTransactionsPropertyDocument') {
         if (empty($model->{$name_field})) {
             throw new Exception("Invalid request. No {$name_field} found.");
         }
         $fileName = $model->{$name_field};
         $src = "upload/transactions/property_document/" . $model->transactions_id . "/" . $fileName;
     } elseif ($className == 'ProUploadDocument') {
         if (empty($model->{$name_field})) {
             throw new Exception("Invalid request. No {$name_field} found.");
         }
         $fileName = $model->{$name_field};
         $src = "upload/document/" . $model->user_id . "/" . $fileName;
     } else {
         throw new Exception('Invalid request.');
     }
     $fileHelper = new FileHelper();
     $fileHelper->forceDownload($src);
 }
開發者ID:jasonhai,項目名稱:onehome,代碼行數:28,代碼來源:ActiveRecord.php

示例2: forceDownload

 public static function forceDownload($model, $name_field, $folder)
 {
     try {
         $className = get_class($model);
         if ($className == 'PrecProductFamily') {
             if (empty($model->{$name_field})) {
                 throw new Exception("Invalid request. No {$name_field} found.");
             }
             $fileName = $model->{$name_field};
             $checkSpace = explode(' ', $model->{$name_field});
             if (count($checkSpace) > 1) {
                 $fileName = rawurlencode($fileName);
             }
             $src = "upload/products/" . $model->id . "/{$folder}/" . $fileName;
         } elseif ($className == 'PrecWhitepaper') {
             if (empty($model->{$name_field})) {
                 throw new Exception("Invalid request. No {$name_field} found.");
             }
             $fileName = $model->{$name_field};
             $checkSpace = explode(' ', $model->{$name_field});
             if (count($checkSpace) > 1) {
                 $fileName = rawurlencode($fileName);
             }
             $src = "upload/{$folder}/" . $model->id . "/" . $fileName;
         } elseif ($className == 'PrecPromotion') {
             if (empty($model->{$name_field})) {
                 throw new Exception("Invalid request. No {$name_field} found.");
             }
             $fileName = $model->{$name_field};
             $checkSpace = explode(' ', $model->{$name_field});
             if (count($checkSpace) > 1) {
                 $fileName = rawurlencode($fileName);
             }
             $src = "upload/promotion/{$folder}/" . $model->id . "/" . $fileName;
         } else {
             throw new Exception('Invalid request.');
         }
         $fileHelper = new FileHelper();
         $fileHelper->forceDownload($src);
     } catch (Exception $exc) {
         throw new Exception($exc->getMessage());
     }
 }
開發者ID:jasonhai,項目名稱:onehome,代碼行數:43,代碼來源:MyFunctionCustom.php


注:本文中的FileHelper::forceDownload方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。