当前位置: 首页>>代码示例>>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;未经允许,请勿转载。