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


PHP File::getExtension方法代码示例

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


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

示例1: completeDataFormat

 /**
  * Establish and set the dataFormat
  * if not set directly.
  *
  * @throws \LogicException
  */
 protected function completeDataFormat()
 {
     $dataFormatIsSetDirectly = isset($this->dataFormat);
     $fileHasExtension = !empty($this->file->getExtension());
     if (!$dataFormatIsSetDirectly && $fileHasExtension) {
         $this->dataFormat = strtolower($this->file->getExtension());
     } elseif (!$dataFormatIsSetDirectly) {
         throw new \LogicException('File has no extension and format has not been set directly. ' . 'File format cannot be established.');
     }
 }
开发者ID:katheroine,项目名称:php-data-coder,代码行数:16,代码来源:AbstractDatafileCoder.php

示例2: __get

 public function __get($var)
 {
     switch ($var) {
         case "name":
             return $this->name;
             break;
         case "size":
             return filesize($this->fullpath);
             break;
         case "fullPath":
             return $this->folder->slashTerm($this->folder->path) . $this->name;
         case "extension":
             return File::getExtension($this->name);
             break;
         case "lastAccess":
             return filemtime($this->fullPath);
             break;
         case "lastChange":
             return filemtime($this->fullPath);
             break;
         case "folder":
             return $this->folder;
             break;
         default:
             return false;
     }
     return false;
 }
开发者ID:stden,项目名称:base-line,代码行数:28,代码来源:file.php

示例3: index

 public function index($file, $parameters = array())
 {
     $file = Path::assemble(BASE_PATH, $file);
     if (File::exists($file)) {
         $fileSize = File::getSize(BASE_PATH . $file);
         switch ($parameters) {
             case "file_ext":
                 return File::getExtension($file);
                 break;
             case "file_size":
                 return File::getSize(BASE_PATH . $file);
                 break;
             case "file_size_kilobytes":
                 return number_format($fileSize / 1024);
                 break;
             case "file_size_human":
                 return self::format_bytes_human($fileSize);
                 break;
             default:
                 return File::getExtension($file);
         }
     } else {
         Log::error("File does not exist or is not readable", "fileinfo_modifier", $file);
     }
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:25,代码来源:mod.fileinfo.php

示例4: compileDir

 public static function compileDir($dir, $destFile)
 {
     $dh = opendir($dir);
     if (!$dh) {
         throw new Exception('Unknown dir: ' . $dir);
     }
     while ($file = readdir($dh)) {
         if ($file[0] == '.') {
             continue;
         }
         $absfile = Dir::normalize($dir) . $file;
         if (is_file($absfile) && File::getExtension($file) == 'js') {
             File::append($destFile, "//FILE: {$file}" . chr(10));
             if (filesize($absfile) > 200000) {
                 File::append($destFile, file_get_contents($absfile));
             } else {
                 File::append($destFile, self::minify($absfile));
             }
             File::append($destFile, chr(10) . chr(10));
         } else {
             if (is_dir($absfile)) {
                 self::compileDir($absfile, $destFile);
             }
         }
     }
     closedir($dh);
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:27,代码来源:Javascript.php

示例5: index

 public function index()
 {
     $file = $this->fetchParam("file", null, null, null, false);
     $fileSize = File::getSize(BASE_PATH . $file);
     $file_info = array("file_ext" => File::getExtension(BASE_PATH . $file), "file_size" => $fileSize, "file_size_kilobytes" => number_format($fileSize / 1024), "file_size_human" => self::format_bytes_human($fileSize));
     return $file_info;
 }
开发者ID:Synergy23,项目名称:RealEstate,代码行数:7,代码来源:pi.fileinfo.php

示例6: __construct

 function __construct($fileName = null)
 {
     if ($fileName) {
         $this->fileName = $fileName;
         $this->extension = strToLower(File::getExtension($fileName));
         $this->load();
     }
 }
开发者ID:NerdZombies,项目名称:MateCode,代码行数:8,代码来源:Bitmap.php

示例7: download

 public static function download($path, $content_type = null, $new_name = null)
 {
     $file = new File($path);
     header('Content-Type: ' . $content_type ? $content_type : $file->getMime());
     header('Content-Disposition: attachment; filename="' . ($new_name ? $new_name : uniqid() . '.' . $file->getExtension()) . '"');
     readfile($path);
     exit;
 }
开发者ID:ramee,项目名称:alien-framework,代码行数:8,代码来源:Response.php

示例8: import

 /**
  * Méthode de chargement de décodage d'un fichier au format spécifique
  * @param String $pFile
  * @return Array
  */
 static function import($pFile)
 {
     switch (strtolower(File::getExtension($pFile))) {
         case "xlsx":
             return self::import_xlsx($pFile);
             break;
     }
     return false;
 }
开发者ID:arno06,项目名称:Achilles,代码行数:14,代码来源:class.SimpleExcel.php

示例9: testExtensionFullAndLast

 function testExtensionFullAndLast()
 {
     $f_txt = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/test_file.txt");
     $this->assertEqual("txt", $f_txt->getFullExtension());
     $this->assertEqual("txt", $f_txt->getExtension());
     $f_css = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/css_test.css");
     $this->assertEqual("css", $f_css->getFullExtension());
     $this->assertEqual("css", $f_css->getExtension());
     $f_plug_txt = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/ext_test.plug.txt");
     $this->assertEqual("plug.txt", $f_plug_txt->getFullExtension());
     $this->assertEqual("txt", $f_plug_txt->getExtension());
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:12,代码来源:plain_file_test.php

示例10: run

 /**
  * Executes the widget.
  */
 public function run()
 {
     if ($this->item->href != '') {
         $this->render('libraryLink', array('item' => $this->item, 'category' => $this->category, 'editable' => $this->editable));
     } else {
         $files = File::getFilesOfObject($this->item);
         $file = array_pop($files);
         // If there is no file attached, deliver a dummy object. That's better than completely breaking the rendering.
         if (!is_object($file)) {
             $file = new File();
         }
         $mime = HHtml::getMimeIconClassByExtension($file->getExtension());
         $this->render('libraryDocument', array('file' => $file, 'mime' => $mime, 'item' => $this->item, 'category' => $this->category, 'editable' => $this->editable));
     }
 }
开发者ID:tejrajs,项目名称:humhub-modules-library,代码行数:18,代码来源:LibraryItemWidget.php

示例11: control

 public function control()
 {
     $this->redirectToSternIndiaEndPoint();
     $config = Config::getInstance();
     if (isset($_POST['upload']) && $_POST['upload'] == 'Upload') {
         $target_dir = new FileSystem('upload/');
         $file = new File('foo', $target_dir);
         $name = date('D_d_m_Y_H_m_s_');
         $name = $name . $file->getName();
         $file->setName($name);
         $config = Config::getInstance();
         $file->addValidations(array(new Mimetype($config->getMimeTypes()), new Size('5M')));
         $data = array('name' => $file->getNameWithExtension(), 'extension' => $file->getExtension(), 'mime' => $file->getMimetype(), 'size' => $file->getSize(), 'md5' => $file->getMd5());
         try {
             // /Profiler::debugPoint(true,__METHOD__, __FILE__, __LINE__,$data);
             $file->upload();
             //Profiler::debugPoint(true,__METHOD__, __FILE__, __LINE__,$data);
         } catch (Exception $e) {
             $errors = $file->getErrors();
         }
         $csvReader = new CSVReader();
         $destinationFile = $target_dir->directory . $file->getNameWithExtension();
         $data = $csvReader->parse_file($destinationFile);
         //$country= DAOFactory::getDAO('LocationDAO');
         foreach ($data as $loc_arr) {
             Utils::processLocation($loc_arr);
         }
         //Profiler::debugPoint(true,__METHOD__, __FILE__, __LINE__);
         $target_dir = "uploads/";
         $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
         $uploadOk = 1;
         $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
         // Check if image file is a actual image or fake image
         if (isset($_POST["submit"])) {
             $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
             if ($check !== false) {
                 echo "File is an image - " . $check["mime"] . ".";
                 $uploadOk = 1;
             } else {
                 echo "File is not an image.";
                 $uploadOk = 0;
             }
         }
     }
     return $this->generateView();
 }
开发者ID:prabhatse,项目名称:olx_hack,代码行数:46,代码来源:class.FileUploadController.php

示例12: index

 public function index($file, $parameters = array())
 {
     switch ($parameters) {
         case "file_ext":
             return File::getExtension();
             break;
         case "file_size":
             return File::getSize(BASE_PATH . $file);
             break;
         case "file_size_kilobytes":
             return number_format($fileSize / 1024);
             break;
         case "file_size_human":
             return self::format_bytes_human($fileSize);
             break;
         default:
             return File::getExtension();
     }
 }
开发者ID:Synergy23,项目名称:RealEstate,代码行数:19,代码来源:mod.fileinfo.php

示例13: createResource

 public function createResource($file)
 {
     $this->type = File::getExtension($file);
     switch ($this->type) {
         case 'jpg':
         case 'jpeg':
             $this->resource = imagecreatefromjpeg($file);
             break;
         case 'gif':
             $this->resource = imagecreatefromgif($file);
             break;
         case 'png':
             $this->resource = imagecreatefrompng($file);
             break;
         case 'bmp':
             $this->resource = imagecreatefromwbmp($file);
             break;
     }
 }
开发者ID:quintenvk,项目名称:quintenvk,代码行数:19,代码来源:Image.php

示例14: getThumbPrevText

 /**
  * Make the text under the image to say what size preview
  *
  * @param $params Array parameters for thumbnail
  * @param $sizeLinkBigImagePreview HTML for the current size
  * @return string HTML output
  */
 private function getThumbPrevText($params, $sizeLinkBigImagePreview)
 {
     if ($sizeLinkBigImagePreview) {
         // Show a different message of preview is different format from original.
         $previewTypeDiffers = false;
         $origExt = $thumbExt = $this->displayImg->getExtension();
         if ($this->displayImg->getHandler()) {
             $origMime = $this->displayImg->getMimeType();
             $typeParams = $params;
             $this->displayImg->getHandler()->normaliseParams($this->displayImg, $typeParams);
             list($thumbExt, $thumbMime) = $this->displayImg->getHandler()->getThumbType($origExt, $origMime, $typeParams);
             if ($thumbMime !== $origMime) {
                 $previewTypeDiffers = true;
             }
         }
         if ($previewTypeDiffers) {
             return $this->getContext()->msg('show-big-image-preview-differ')->rawParams($sizeLinkBigImagePreview)->params(strtoupper($origExt))->params(strtoupper($thumbExt))->parse();
         } else {
             return $this->getContext()->msg('show-big-image-preview')->rawParams($sizeLinkBigImagePreview)->parse();
         }
     } else {
         return '';
     }
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:31,代码来源:ImagePage.php

示例15: createFileJSON

 /**
  * Given a File object, create an array of its properties and values
  * ready to be transformed to JSON
  * 	
  * @param  Folder $folder
  * @return array
  */
 public function createFileJSON(File $file, $folder = null)
 {
     $isImage = $file instanceof Image;
     $w = $isImage ? self::IMAGE_WIDTH : self::ICON_SIZE;
     $h = $isImage ? self::IMAGE_HEIGHT : self::ICON_SIZE;
     $folder = $folder ?: $file->Parent();
     return array('id' => $file->ID, 'parentID' => $file->ParentID, 'title' => $file->Title, 'filename' => basename($file->Filename), 'path' => $file->Filename, 'filesize' => $file->getAbsoluteSize(), 'folderName' => $folder->Filename, 'type' => $isImage ? 'image' : 'file', 'extension' => $file->getExtension(), 'created' => $file->Created, 'updated' => $file->LastEdited, 'iconURL' => $file->getPreviewThumbnail($w, $h)->URL, 'canEdit' => $file->canEdit(), 'canCreate' => $file->canCreate(), 'canDelete' => $file->canDelete());
 }
开发者ID:helpfulrobot,项目名称:unclecheese-kickassets,代码行数:15,代码来源:KickAssets.php


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