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


PHP FileToolkit::getFileExtension方法代碼示例

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


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

示例1: addFile

 public function addFile(array $fileInfo = array(), UploadedFile $originalFile = null)
 {
     $errors = FileToolkit::validateFileExtension($originalFile);
     if ($errors) {
         @unlink($originalFile->getRealPath());
         throw $this->createServiceException("該文件格式,不允許上傳。");
     }
     $uploadFile = array();
     $uploadFile['storage'] = 'local';
     $uploadFile['filename'] = $originalFile->getClientOriginalName();
     $uploadFile['ext'] = FileToolkit::getFileExtension($originalFile);
     $uploadFile['size'] = $originalFile->getSize();
     $filename = FileToolkit::generateFilename($uploadFile['ext']);
     $uploadFile['hashId'] = "course/{$filename}";
     $uploadFile['convertHash'] = "ch-{$uploadFile['hashId']}";
     $uploadFile['convertStatus'] = 'none';
     $uploadFile['type'] = FileToolkit::getFileTypeByExtension($uploadFile['ext']);
     $uploadFile['isPublic'] = empty($fileInfo['isPublic']) ? 0 : 1;
     $uploadFile['canDownload'] = empty($uploadFile['canDownload']) ? 0 : 1;
     $uploadFile['updatedUserId'] = $uploadFile['createdUserId'] = $this->getCurrentUser()->id;
     $uploadFile['updatedTime'] = $uploadFile['createdTime'] = time();
     $targetPath = $this->getFilePath('course', $uploadFile['isPublic']);
     $originalFile->move($targetPath, $filename);
     return $uploadFile;
 }
開發者ID:liugang19890719,項目名稱:www.zesow.com,代碼行數:25,代碼來源:LocalFileImplementorImpl.php

示例2: addFile

 public function addFile($targetType, $targetId, array $fileInfo = array(), UploadedFile $originalFile = null)
 {
     $errors = FileToolkit::validateFileExtension($originalFile);
     if ($errors) {
         @unlink($originalFile->getRealPath());
         throw $this->createServiceException("該文件格式,不允許上傳。");
     }
     $uploadFile = array();
     $time = time();
     $uploadFile['storage'] = 'local';
     $uploadFile['targetId'] = $targetId;
     $uploadFile['targetType'] = $targetType;
     $uploadFile['filename'] = $originalFile->getClientOriginalName();
     //$uploadFile['filename'] = $time.$uploadFile['filename'];
     $uploadFile['ext'] = FileToolkit::getFileExtension($originalFile);
     $uploadFile['size'] = $originalFile->getSize();
     $filename = FileToolkit::generateFilename($uploadFile['ext']);
     $uploadFile['hashId'] = "{$uploadFile['targetType']}/{$uploadFile['targetId']}/{$filename}";
     $uploadFile['convertHash'] = "ch-{$uploadFile['hashId']}";
     $uploadFile['convertStatus'] = 'none';
     $uploadFile['type'] = FileToolkit::getFileTypeByExtension($uploadFile['ext']);
     $uploadFile['isPublic'] = empty($fileInfo['isPublic']) ? 0 : 1;
     $uploadFile['canDownload'] = empty($uploadFile['canDownload']) ? 0 : 1;
     $uploadFile['updatedUserId'] = $uploadFile['createdUserId'] = $this->getCurrentUser()->id;
     $uploadFile['updatedTime'] = $uploadFile['createdTime'] = time();
     //$uploadFile['filePath'] = $this->getFilePath();
     //throw new \RuntimeException(print_r('ssd'));
     //throw $this->createServiceException(print_r('ssd'));
     //$key = $uploadFile['filename'];
     //qiniu();
     //轉存上傳臨時文件到資源文件夾(由於業務服務器硬盤較小,故不作備份,直接上傳到七牛雲。如需開啟則刪除下麵注釋符) 以下代碼未包含刪備份
     $targetPath = $this->getFilePath($targetType, $targetId, $uploadFile['isPublic']);
     $originalFile->move($targetPath, $filename);
     //todo 上傳到七牛處理代碼(存儲、轉碼、拚接、水印)20151224
     //$config = $this->getQiniuService()->initQiniu($targetPath,$filename);
     return $uploadFile;
 }
開發者ID:Loyalsoldier,項目名稱:8000wei-v3,代碼行數:37,代碼來源:LocalFileImplementorImpl.php


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