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


PHP Folder::isWritable方法代码示例

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


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

示例1: redactor__upload

 public function redactor__upload()
 {
     if (!Auth::getCurrentMember()) {
         exit("Invalid Request");
     }
     $path = Request::get('path');
     $is_image = Request::get('is_image');
     if (isset($path)) {
         $dir = Path::tidy(ltrim($path, '/') . '/');
         if (isset($_POST['subfolder'])) {
             $dir .= $_POST['subfolder'] . '/';
         }
         Folder::make($dir);
         $file_type = strtolower($_FILES['file']['type']);
         $file_info = pathinfo($_FILES['file']['name']);
         // pull out the filename bits
         $filename = $file_info['filename'];
         $ext = $file_info['extension'];
         // build filename
         $file = $dir . $filename . '.' . $ext;
         // check for dupes
         if (File::exists($file)) {
             $file = BASE_PATH . '/' . $dir . $filename . '-' . date('YmdHis') . '.' . $ext;
         }
         if (!Folder::isWritable($dir)) {
             Log::error('Upload failed. Directory "' . $dir . '" is not writable.', 'redactor');
             echo json_encode(array('error' => "Redactor: Upload directory not writable."));
             die;
         }
         if ($is_image && ($_FILES['file']['type'] == 'image/png' || $_FILES['file']['type'] == 'image/jpg' || $_FILES['file']['type'] == 'image/gif' || $_FILES['file']['type'] == 'image/jpeg')) {
             if (Request::get('resize', false)) {
                 $image = Image::make($_FILES['file']['tmp_name']);
                 $width = Request::get('width', null);
                 $height = Request::get('height', null);
                 $ratio = Request::get('ratio', true);
                 $upsize = Request::get('upsize', false);
                 $quality = Request::get('quality', '75');
                 $image->resize($width, $height, $ratio, $upsize)->save($file, $quality);
             } else {
                 move_uploaded_file($_FILES['file']['tmp_name'], $file);
             }
         } else {
             move_uploaded_file($_FILES['file']['tmp_name'], $file);
         }
         $return = array('filelink' => Path::toAsset($file));
         echo stripslashes(json_encode($return));
     } else {
         echo json_encode(array('error' => "Redactor: Upload directory not set."));
     }
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:50,代码来源:hooks.redactor.php

示例2: redactor__upload

 public function redactor__upload()
 {
     if (!Statamic_Auth::get_current_user()) {
         exit("Invalid Request");
     }
     $path = Request::get('path');
     if (isset($path)) {
         $dir = Path::tidy(ltrim($path, '/') . '/');
         if (isset($_POST['subfolder'])) {
             $dir .= $_POST['subfolder'] . '/';
         }
         Folder::make($dir);
         $_FILES['file']['type'] = strtolower($_FILES['file']['type']);
         if ($_FILES['file']['type'] == 'image/png' || $_FILES['file']['type'] == 'image/jpg' || $_FILES['file']['type'] == 'image/gif' || $_FILES['file']['type'] == 'image/jpeg') {
             $file_info = pathinfo($_FILES['file']['name']);
             // pull out the filename bits
             $filename = $file_info['filename'];
             $ext = $file_info['extension'];
             // build filename
             $file = $dir . $filename . '.' . $ext;
             // check for dupes
             if (File::exists($file)) {
                 $file = $dir . $filename . '-' . date('YmdHis') . '.' . $ext;
             }
             if (!Folder::isWritable($dir)) {
                 Log::error('Upload failed. Directory "' . $dir . '" is not writable.', 'redactor');
                 echo json_encode(array('error' => "Redactor: Upload directory not writable."));
                 die;
             }
             copy($_FILES['file']['tmp_name'], $file);
             // display file
             $array = array('filelink' => Config::getSiteRoot() . $file);
             echo stripslashes(json_encode($array));
         } else {
             echo json_encode(array('error' => "Redactor: Could not find directory: '{$dir}'"));
         }
     } else {
         echo json_encode(array('error' => "Redactor: Upload directory not set."));
     }
 }
开发者ID:nob,项目名称:joi,代码行数:40,代码来源:hooks.redactor.php

示例3: upload

 /**
  * Upload a file.
  *
  * @param string  $file  Name of file
  * @param string  $target  target of file
  * @param string  $filename  Name of new file
  * @return bool
  **/
 public static function upload($file, $destination, $add_root_variable = false, $renamed_file = false)
 {
     Folder::make($destination);
     $info = pathinfo($file['name']);
     $extension = $info['extension'];
     $filename = $renamed_file ?: $info['filename'];
     // build filename
     $new_filename = Path::assemble(BASE_PATH, $destination, $filename . '.' . $extension);
     // check for dupes
     if (File::exists($new_filename)) {
         $new_filename = Path::assemble(BASE_PATH, $destination, $filename . '-' . date('YmdHis') . '.' . $extension);
     }
     // Check if destination is writable
     if (!Folder::isWritable($destination)) {
         Log::error('Upload failed. Directory "' . $destination . '" is not writable.', 'core');
         return null;
     }
     // write file
     move_uploaded_file($file['tmp_name'], $new_filename);
     return Path::toAsset($new_filename, $add_root_variable);
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:29,代码来源:file.php

示例4: isWritable

 /**
  * Checks if the page or any of its files are writable
  *
  * @return boolean
  */
 public function isWritable()
 {
     $folder = new Folder($this->root());
     if (!$folder->isWritable()) {
         return false;
     }
     foreach ($folder->files() as $f) {
         if (!$f->isWritable()) {
             return false;
         }
     }
     return true;
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:18,代码来源:page.php

示例5: are_users_writable

 public static function are_users_writable()
 {
     return Folder::isWritable('_config/users/');
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:4,代码来源:statamic.php

示例6: checkContent

 protected static function checkContent()
 {
     $folder = new Folder(kirby()->roots()->content());
     return $folder->isWritable(true);
 }
开发者ID:aoimedia,项目名称:kosmonautensofa,代码行数:5,代码来源:installation.php

示例7: checkContent

 protected static function checkContent()
 {
     $folder = new Folder(c::get('root.content'));
     return $folder->isWritable(true);
 }
开发者ID:kompuser,项目名称:panel,代码行数:5,代码来源:installation.php


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