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


PHP File::ext方法代碼示例

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


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

示例1: File

 function admin_upload_photo($image = null)
 {
     $path = "img\\products\\";
     $dir = WWW_ROOT . $path;
     //trenutna lokacija slike
     $imageTmp = $image['Product']['file']['tmp_name'];
     $imageName = $image['Product']['file']['name'];
     $file = new File($imageTmp);
     //preverjanje koncnic za sliko
     $ext = $file->ext();
     /*  
     	    if($ext != 'jpg' || $ext != 'jpeg' || $ext != 'png' || $ext != 'gif'){
     	        pr('Wrong extension - ');
     	        print_r($file);
     	        die;
     	        return false;
     	    }*/
     $fileData = $file->read();
     $file->close();
     //zapis v nov fajl
     $file = new File($dir . $imageName, true);
     $file->write($fileData);
     $file->close();
     //nastavitev pd_image na ime slike (ker je se vedno array())
     return $imageName;
 }
開發者ID:johnulist,項目名稱:ecommerce,代碼行數:26,代碼來源:product.php

示例2: admin_view

 public function admin_view($id = null)
 {
     $filename = WWW_ROOT . FilesController::FILE_ROOT . DS . implode(DS, $this->request->params['pass']) . "." . $this->request->params['ext'];
     debug($filename);
     $file = new File($filename, false);
     if (!$file->exists()) {
         throw new NotFoundException(__('File not found: ') . $file->path);
     }
     debug($file->name);
     debug($file->ext());
     debug($file->Folder()->path);
     $this->viewClass = 'Media';
     $params = array('id' => $file->name, 'name' => $file->name(), 'download' => false, 'extension' => $file->ext(), 'path' => $file->Folder()->path . DS);
     $this->set($params);
     //$this->set('fee', $this->Fee->read(null, $id));
 }
開發者ID:barkow,項目名稱:ringelsoeckchen,代碼行數:16,代碼來源:FilesController.php

示例3: read

 /**
  * Reads a MagicDb from various formats
  *
  * @var $magicDb mixed Can be an array containing the db, a magic db as a string, or a filename pointing to a magic db in .db or magic.db.php format
  * @return boolean Returns false if reading / validation failed or true on success.
  * @access private
  */
 public function read($magicDb = null)
 {
     if (!is_string($magicDb) && !is_array($magicDb)) {
         return false;
     }
     if (is_array($magicDb) || strpos($magicDb, '# FILE_ID DB') === 0) {
         $data = $magicDb;
     } else {
         $File = new File($magicDb);
         if (!$File->exists()) {
             return false;
         }
         if ($File->ext() == 'php') {
             include $File->pwd();
             $data = $magicDb;
         } else {
             // @TODO: Needs test coverage
             $data = $File->read();
         }
     }
     $magicDb = $this->toArray($data);
     if (!$this->validates($magicDb)) {
         return false;
     }
     return !!($this->db = $magicDb);
 }
開發者ID:evrard,項目名稱:cakephp2x,代碼行數:33,代碼來源:magic_db.php

示例4: findByChildren

 /**
  * ImageHelper::findByExtention()
  *
  * @param mixed $extention
  * @return
  */
 function findByChildren($children = array())
 {
     $images = Configure::read('CoreImages.images');
     if (empty($children[1])) {
         return $this->Html->image(Configure::read('CoreImages.path') . 'folders/' . $images['folders']['empty'], $this->settings + array('title' => __('Empty Folder'), 'alt' => __('Empty Folder')));
     }
     App::import('File');
     foreach ($children[1] as $child) {
         $File = new File($child);
         $ext = $File->ext();
         if (!isset($data[$ext])) {
             $data[$ext] = 0;
             continue;
         }
         $data[$ext]++;
         unset($File);
     }
     $highest = 0;
     $_ext = '';
     foreach ($data as $k => $v) {
         if ($v > $highest) {
             $highest = $v;
             $_ext = $k;
         }
     }
     return $this->findByExtention($_ext);
 }
開發者ID:nani8124,項目名稱:infinitas,代碼行數:33,代碼來源:ImageHelper.php

示例5: format

 /**
  * Determine the format of given database
  *
  * @param mixed $db
  */
 function format($db)
 {
     if (empty($db)) {
         return null;
     }
     if (is_array($db)) {
         return 'Array';
     }
     if (!is_string($db)) {
         return null;
     }
     $File = new File($db);
     if ($File->exists()) {
         if ($File->ext() === 'php') {
             return 'PHP';
         }
         $File->open('rb');
         $head = $File->read(4096);
         if (preg_match('/^(\\d{2}:)?[-\\w.+]*\\/[-\\w.+]+:[\\*\\.a-zA-Z0-9]*$/m', $head)) {
             return 'Freedesktop Shared MIME-info Database';
         } elseif (preg_match('/^[-\\w.+]*\\/[-\\w.+]+\\s+[a-zA-Z0-9]*$/m', $head)) {
             return 'Apache Module mod_mime';
         }
     }
     return null;
 }
開發者ID:essemme,項目名稱:media,代碼行數:31,代碼來源:mime_glob.php

示例6: file_extension

 protected function file_extension($value, $params)
 {
     $allowed_exts = $params['extension'];
     $f = new File($value['name']);
     $problems = array();
     if (is_array($allowed_exts)) {
         if (!in_array(strtolower($f->ext()), $allowed_exts)) {
             $problems[] = 'A extensão do arquivo deve ser ' . join(',', $allowed_exts);
         }
     } else {
         if ($f->ext() != $allowed_exts) {
             $problems[] = 'A extensão do arquivo deve ser ' . $allowed_exts;
         }
     }
     if (count($problems) == 0) {
         return false;
     }
     return $problems;
 }
開發者ID:michelmfreitas,項目名稱:iPixels-Restaurante,代碼行數:19,代碼來源:FileValidatorComponent.php

示例7: _evaluate

 /**
  * Evalute a view file, rendering it's contents
  *
  * @return string The output
  */
 protected function _evaluate($viewFile, $dataForView)
 {
     $file = new File($viewFile);
     if ($file->ext() != self::$extension) {
         return parent::_evaluate($viewFile, $dataForView);
     }
     $file = $this->_createRenderedView($viewFile);
     $content = parent::_evaluate($file, $dataForView);
     $this->_deleteRenderedView($file);
     return $content;
 }
開發者ID:tiutalk,項目名稱:haml,代碼行數:16,代碼來源:HamlView.php

示例8: File

 /**
  *
  * @param  $data
  * @return bool
  */
 function validate_file($data)
 {
     try {
         $file_name = $data['upload']['name'];
         if (!empty($file_name)) {
             $tempFile = new File($file_name);
             $ext = $tempFile->ext();
             $ext = strtolower($ext);
             $types = array("gif", "jpg", "jpeg", "png", "pjpeg", "x-png", "x-tiff");
             $val = in_array($ext, $types, true);
             if ($val) {
                 return true;
             }
             return false;
         }
         return true;
     } catch (Exception $exception) {
         echo $exception->getMessage();
     }
 }
開發者ID:89itworld,項目名稱:digisticker,代碼行數:25,代碼來源:Sticker.php

示例9: __new__

 protected function __new__($file_path)
 {
     $this->cmd = def("arbo.io.FFmpeg@cmd", "/usr/local/bin/ffmpeg");
     $info = Command::error(sprintf("%s -i %s", $this->cmd, $file_path));
     $file = new File($file_path);
     $this->name = $file->oname();
     $this->ext = $file->ext();
     $this->filename = $file_path;
     $this->framerate = preg_match("/frame rate: .+ -> ?([\\d\\.]+)/", $info, $match) ? (double) $match[1] : null;
     $this->bitrate = preg_match("/bitrate: (\\d+)/", $info, $match) ? (double) $match[1] : null;
     $this->duration = preg_match("/Duration: ([\\d\\:\\.]+)/", $info, $match) ? Date::parse_time($match[1]) : null;
     if (preg_match("/Video: (.+)/", $info, $match)) {
         $video = explode(",", $match[1]);
         if (isset($video[0])) {
             $this->video_codec = trim($video[0]);
         }
         if (isset($video[1])) {
             $this->format = trim($video[1]);
         }
         if (isset($video[2])) {
             list($this->width, $this->height) = explode("x", trim($video[2]));
             if (preg_match("/(\\d+) .+DAR (\\d+\\:\\d+)/", $this->height, $match)) {
                 list(, $this->height, $this->aspect) = $match;
             }
         }
         if (empty($this->aspect) && isset($video[3])) {
             $this->aspect = preg_match("/DAR (\\d+\\:\\d+)/", $video[3], $match) ? $match[1] : null;
         }
     }
     if (preg_match("/Audio: (.+)/", $info, $match)) {
         $audio = explode(",", $match[1]);
         if (isset($audio[0])) {
             $this->audio_codec = trim($audio[0]);
         }
         if (isset($audio[1])) {
             $this->samplerate = preg_match("/\\d+/", $audio[1], $match) ? $match[0] : null;
         }
     }
     $this->frame_count = ceil($this->duration * $this->framerate);
 }
開發者ID:hisaboh,項目名稱:w2t,代碼行數:40,代碼來源:FFmpeg.php

示例10: ShortCode

 public static function ShortCode($arguments)
 {
     extract($arguments);
     // Obtain json file on public folder
     $id = $id ? $id : '';
     $json = '';
     $galleryFile = ROOT_DIR . '/public/gallery/gallery.json';
     if (File::exists($galleryFile)) {
         $json = json_decode(File::getContent($galleryFile), true);
     } else {
         die('OOps Whrere is media.json file!');
     }
     $num = 0;
     $photos = File::scan(ROOT_DIR . '/public/gallery/galleries/' . $id);
     $img = Url::getBase() . '/public/gallery/galleries/' . $id . '/' . File::name($photos[0]) . '.' . File::ext($photos[0]);
     // get plugin info
     //var_dump(json_encode(Config::get('plugins.gallery'),true));
     $template = Template::factory(PLUGINS_PATH . '/gallery/templates/');
     $template->setOptions(['strip' => false]);
     // show template
     return $template->fetch('slide.tpl', ['id' => $id, 'title' => $json[$id]['title'], 'description' => $json[$id]['desc'], 'first' => $img, 'photos' => $photos]);
 }
開發者ID:nakome,項目名稱:Fansoro-gallery-plugin,代碼行數:22,代碼來源:gallery_functions.php

示例11: uploadPhoto

 public function uploadPhoto($data)
 {
     $validtypes = array('png', 'gif', 'jpg', 'jpeg', 'pjpeg', 'bmp');
     $filetype = substr($data['photo']['type'], 6);
     if (in_array($filetype, $validtypes)) {
         $this->deletePhoto();
         // Delete previous photo.
         $tmp_file = new File($data['photo']['tmp_name']);
         if ($filetype == 'jpeg' || $filetype == 'pjpeg') {
             $filetype = 'jpg';
         }
         $filename = 'img/users/' . AuthComponent::user('username') . '.' . $filetype;
         $file = new File($filename, true);
         $file->write($tmp_file->read());
         // Write new photo.
         if ($file->executable() || !in_array($file->ext(), $validtypes)) {
             $file->delete();
             return false;
         }
         return true;
     }
     return false;
 }
開發者ID:nsystem1,項目名稱:cwt,代碼行數:23,代碼來源:Profile.php

示例12: import

 static function import()
 {
     #>> import modules
     foreach (func_get_args() as $unit) {
         # get the real file name
         $unit = ABS_PATH . str_replace('.', '/', $unit);
         # get the dir from the unit name
         $dir = dirname($unit);
         # imports all the php scripts from the dir
         if (substr($unit, -1) == '*' && ($dh = opendir($dir))) {
             while (($file = readdir($dh)) !== false) {
                 if (File::ext($file) == 'php') {
                     # import the script
                     require_once $dir . '/' . $file;
                 }
             }
             closedir($dh);
         } else {
             if (is_file($unit .= '.php')) {
                 require_once $unit;
             }
         }
     }
 }
開發者ID:kayohf,項目名稱:simple,代碼行數:24,代碼來源:base.php

示例13: format

 /**
  * Determine the format of given database
  *
  * @param mixed $db
  */
 function format($db)
 {
     if (empty($db)) {
         return null;
     }
     if (is_array($db)) {
         return 'Array';
     }
     if (!is_string($db)) {
         return null;
     }
     $File = new File($db);
     if ($File->exists()) {
         if ($File->ext() === 'php') {
             return 'PHP';
         }
         $File->open('rb');
         $head = $File->read(4096);
         if (substr($head, 0, 12) === "MIME-Magic\n") {
             return 'Freedesktop Shared MIME-info Database';
         }
         if (preg_match('/^(\\>*)(\\d+)\\t+(\\S+)\\t+([\\S^\\040]+)\\t*([-\\w.\\+]+\\/[-\\w.\\+]+)*\\t*(\\S*)$/m', $head)) {
             return 'Apache Module mod_mime_magic';
         }
     }
     return null;
 }
開發者ID:razzman,項目名稱:media,代碼行數:32,代碼來源:MimeMagic.php

示例14: file

 /**
  * Setup for display or download the given file.
  *
  * If $_SERVER['HTTP_RANGE'] is set a slice of the file will be
  * returned instead of the entire file.
  *
  * ### Options keys
  *
  * - name: Alternate download name
  * - download: If `true` sets download header and forces file to be downloaded rather than displayed in browser
  *
  * @param string $path Path to file. If the path is not an absolute path that resolves
  *   to a file, `APP` will be prepended to the path.
  * @param array $options Options See above.
  * @return void
  * @throws NotFoundException
  */
 public function file($path, $options = array())
 {
     $options += array('name' => null, 'download' => null);
     if (strpos($path, '../') !== false || strpos($path, '..\\') !== false) {
         throw new NotFoundException(__d('cake_dev', 'The requested file contains `..` and will not be read.'));
     }
     if (!is_file($path)) {
         $path = APP . $path;
     }
     $file = new File($path);
     if (!$file->exists() || !$file->readable()) {
         if (Configure::read('debug')) {
             throw new NotFoundException(__d('cake_dev', 'The requested file %s was not found or not readable', $path));
         }
         throw new NotFoundException(__d('cake', 'The requested file was not found'));
     }
     $extension = strtolower($file->ext());
     $download = $options['download'];
     if ((!$extension || $this->type($extension) === false) && $download === null) {
         $download = true;
     }
     $fileSize = $file->size();
     if ($download) {
         $agent = env('HTTP_USER_AGENT');
         if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent)) {
             $contentType = 'application/octet-stream';
         } elseif (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
             $contentType = 'application/force-download';
         }
         if (!empty($contentType)) {
             $this->type($contentType);
         }
         if ($options['name'] === null) {
             $name = $file->name;
         } else {
             $name = $options['name'];
         }
         $this->download($name);
         $this->header('Content-Transfer-Encoding', 'binary');
     }
     $this->header('Accept-Ranges', 'bytes');
     $httpRange = env('HTTP_RANGE');
     if (isset($httpRange)) {
         $this->_fileRange($file, $httpRange);
     } else {
         $this->header('Content-Length', $fileSize);
     }
     $this->_clearBuffer();
     $this->_file = $file;
 }
開發者ID:xplico,項目名稱:CapAnalysis,代碼行數:67,代碼來源:CakeResponse.php

示例15: cleanGeneratedCss

 /**
  * Clean the generated CSS files
  *
  * @return array
  */
 public function cleanGeneratedCss()
 {
     $this->_removeCacheKey('sass_compiled');
     // Cleaned files that we will return
     $cleanedFiles = array();
     foreach ($this->_sassFolders as $key => $sassFolder) {
         foreach ($sassFolder->find() as $file) {
             $file = new File($file);
             if (($file->ext() == 'sass' || $file->ext() == 'scss') && substr($file->name, 0, 2) !== '._') {
                 $sassFile = $sassFolder->path . DS . $file->name;
                 $cssFile = $this->_cssFolders[$key]->path . DS . str_replace(array('.sass', '.scss'), '.css', $file->name);
                 if (file_exists($cssFile)) {
                     unlink($cssFile);
                     $cleanedFiles[] = $cssFile;
                 }
             }
         }
     }
     // Remove all cache files at once
     if (is_dir($this->_cacheFolder)) {
         @closedir($this->_cacheFolder);
         $folder = new Folder($this->_cacheFolder);
         $folder->delete();
         unset($folder);
         $cleanedFiles[] = $this->_cacheFolder . DS . '*';
     }
     mkdir($this->_cacheFolder);
     return $cleanedFiles;
 }
開發者ID:jxav,項目名稱:SassCompiler,代碼行數:34,代碼來源:SassComponent.php


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