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


PHP f::filename方法代码示例

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


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

示例1: avatar

 public function avatar()
 {
     if (isset($this->cache['avatar'])) {
         return $this->cache['avatar'];
     }
     // try to find the avatar
     $root = c::get('root') . DS . 'assets' . DS . 'avatars' . DS . $this->username() . '.{jpg,png}';
     if ($avatar = a::first((array) glob($root, GLOB_BRACE))) {
         return $this->cache['avatar'] = new Media($avatar, url('assets/avatars/' . f::filename($avatar)));
     } else {
         return $this->cache['avatar'] = false;
     }
 }
开发者ID:gBokiau,项目名称:kirby,代码行数:13,代码来源:user.php

示例2: __construct

 public function __construct(User $user)
 {
     // store the parent user object
     $this->user = $user;
     // this should rather be coming from the user object
     $this->kirby = kirby::instance();
     // try to find the avatar
     if ($file = f::resolve($this->kirby->roots()->avatars() . DS . $user->username(), ['jpg', 'jpeg', 'gif', 'png'])) {
         $filename = f::filename($file);
     } else {
         $filename = $user->username() . '.jpg';
         $file = $this->kirby->roots()->avatars() . DS . $filename;
     }
     parent::__construct($file, $this->kirby->urls()->avatars() . '/' . $filename);
 }
开发者ID:kgchoy,项目名称:main-portfolio-website,代码行数:15,代码来源:avatar.php

示例3: file

 function file($field, $destination, $params = array())
 {
     $allowed = a::get($params, 'allowed', c::get('upload.allowed', array('image/jpeg', 'image/png', 'image/gif')));
     $maxsize = a::get($params, 'maxsize', c::get('upload.maxsize', self::max_size()));
     $overwrite = a::get($params, 'overwrite', c::get('upload.overwrite', true));
     $sanitize = a::get($params, 'sanitize', true);
     $file = a::get($_FILES, $field);
     if (empty($file)) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.missing-file', 'The file has not been found'));
     }
     $name = a::get($file, 'name');
     $type = a::get($file, 'type');
     $tmp_name = a::get($file, 'tmp_name');
     $error = a::get($file, 'error');
     $size = a::get($file, 'size');
     $msg = false;
     $extension = self::mime_to_extension($type, 'jpg');
     // convert the filename to a save name
     $fname = $sanitize ? f::safe_name(f::name($name)) : f::name($name);
     // setup the destination
     $destination = str_replace('{name}', $fname, $destination);
     $destination = str_replace('{extension}', $extension, $destination);
     if (file_exists($destination) && $overwrite == false) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.file-exists', 'The file exists and cannot be overwritten'));
     }
     if (empty($tmp_name)) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.missing-file', 'The file has not been found'));
     }
     if ($error != 0) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.invalid-upload', 'The upload failed'));
     }
     if ($size > $maxsize) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.too-big', 'The file is too big'));
     }
     if (!in_array($type, $allowed)) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.invalid-file', 'The file type is not allowed') . ': ' . $type);
     }
     // try to change the permissions for the destination
     @chmod(dirname($destination), 0777);
     if (!@copy($tmp_name, $destination)) {
         return array('status' => 'error', 'msg' => l::get('upload.errors.move-error', 'The file could not be moved to the server'));
     }
     // try to change the permissions for the final file
     @chmod($destination, 0777);
     return array('status' => 'success', 'msg' => l::get('upload.success', 'The file has been uploaded'), 'type' => $type, 'extension' => $extension, 'file' => $destination, 'size' => $size, 'name' => f::filename($destination));
 }
开发者ID:o-github-o,项目名称:jQuery-Ajax-Upload,代码行数:46,代码来源:upload.php

示例4: download

 public static function download($file, $name = null)
 {
     // stop the download if the file does not exist or is not readable
     if (!is_file($file) or !is_readable($file)) {
         return false;
     }
     header::download(array('name' => $name ? $name : f::filename($file), 'size' => f::size($file), 'mime' => f::mime($file), 'modified' => f::modified($file)));
     die(f::read($file));
 }
开发者ID:chrishiam,项目名称:LVSL,代码行数:9,代码来源:f.php

示例5: avatar

 public function avatar()
 {
     if (isset($this->cache['avatar'])) {
         return $this->cache['avatar'];
     }
     // allowed extensions
     $extensions = array('jpg', 'jpeg', 'png', 'gif');
     // try to find the avatar
     $root = kirby::instance()->roots()->avatars() . DS . $this->username();
     foreach ($extensions as $ext) {
         $file = $root . '.' . $ext;
         if (file_exists($file)) {
             return $this->cache['avatar'] = new Media($file, kirby::instance()->urls()->avatars() . '/' . f::filename($file));
         }
     }
     return $this->cache['avatar'] = false;
 }
开发者ID:irenehilber,项目名称:kirby-base,代码行数:17,代码来源:user.php

示例6: testFilename

 public function testFilename()
 {
     $this->assertEquals('content.php', f::filename($this->contentFile));
 }
开发者ID:aoimedia,项目名称:kosmonautensofa,代码行数:4,代码来源:FTest.php


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