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


PHP filesystem::createDirectory方法代码示例

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


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

示例1: createFolder

 /**
  * Helper function to create a directory if it doesn't exist.
  * @param <type> $path Path to dir to create
  * @return <type>
  */
 private function createFolder($path)
 {
     /* check if folder exists */
     return is_dir($path) or filesystem::createDirectory($path);
 }
开发者ID:swk,项目名称:bluebox,代码行数:10,代码来源:globalmedia.php

示例2: prepare_upload

 public function prepare_upload($uploadvar = 'upload')
 {
     if (!arr::get($_FILES, 'mediafile', 'name', $uploadvar)) {
         kohana::log('error', 'Attempted to prepare upload without file');
         return 'Please provide a file to upload';
     }
     $uploadedFile = arr::get(arr::rotate($_FILES['mediafile']), $uploadvar);
     switch ($uploadedFile['error']) {
         case UPLOAD_ERR_INI_SIZE:
             return 'File exceeds upload_max_filesize';
         case UPLOAD_ERR_FORM_SIZE:
             return 'File exceeds MAX_FILE_SIZE';
         case UPLOAD_ERR_PARTIAL:
             return 'File was only partially uploaded';
         case UPLOAD_ERR_NO_FILE:
             return 'No file was uploaded';
         case UPLOAD_ERR_NO_TMP_DIR:
             return 'Missing a temporary folder';
         case UPLOAD_ERR_CANT_WRITE:
             return 'Failed to write file to disk';
         case UPLOAD_ERR_EXTENSION:
             return 'Invalid file extension (type)';
         case UPLOAD_ERR_OK:
             if (!$this->get('file')) {
                 $uploadFilename = $uploadedFile['name'];
                 if (Kohana::config('upload.remove_spaces') === TRUE) {
                     $uploadFilename = preg_replace('/\\s+/', '_', $uploadFilename);
                 }
                 $this->set('file', $uploadFilename);
             }
             if ($this->get('path')) {
                 $path = trim($this->get('path'), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
                 $this->set('path', $path);
             }
             if (!is_file($uploadedFile['tmp_name'])) {
                 kohana::log('error', 'Unable to locate file in temporary storage ' . $uploadedFile['tmp_name']);
                 return 'Unable to upload file';
             }
             if (!($mediainfo = MediaLib::getAudioInfo($uploadedFile['tmp_name']))) {
                 kohana::log('error', 'Unable to determine audio info for tmp upload file "' . $uploadedFile['tmp_name'] . '"');
                 return 'Upload is not a valid audio file or format';
             }
             $this->fromArray($mediainfo);
             if (kohana::config('mediafile.upload_to_rate_folders')) {
                 $rate = $this->get('rates');
                 $path = $this->get('path');
                 if (in_array($rate, kohana::config('mediafile.default_rates')) and !strstr($path, $rate . DIRECTORY_SEPARATOR)) {
                     $path .= $this->get('rates') . DIRECTORY_SEPARATOR;
                     $this->set('path', $path);
                 } else {
                     if ($unknownPath = kohana::config('mediafile.unknown_rate_folder')) {
                         $path .= trim($unknownPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
                         $this->set('path', $path);
                     }
                 }
             }
             $directory = $this->filepath();
             if (!$this->get('name') or !$this->get('description')) {
                 $mediafiles = $this->get_resampled();
                 if (!$this->get('name')) {
                     if (isset($mediafiles[0]['name'])) {
                         $this->set('name', $mediafiles[0]['name']);
                     } else {
                         $this->set('name', pathinfo($uploadedFile['name'], PATHINFO_FILENAME));
                     }
                 }
                 if (!$this->get('description')) {
                     if (isset($mediafiles[0]['description'])) {
                         $this->set('description', $mediafiles[0]['description']);
                     }
                 }
             }
             if (!$directory or !filesystem::is_writable($directory) and !filesystem::createDirectory($directory)) {
                 kohana::log('error', 'The configured media dir is not writable, please chmod "' . $directory . '"');
                 return 'Media collection directory is not writable';
             }
             $this->uploaded_file = $uploadedFile;
             break;
         default:
             return 'Upload failed for an unspecified reason';
     }
     return FALSE;
 }
开发者ID:swk,项目名称:bluebox,代码行数:83,代码来源:MediaFile.php


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