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


PHP mkdir函数代码示例

本文整理汇总了PHP中mkdir函数的典型用法代码示例。如果您正苦于以下问题:PHP mkdir函数的具体用法?PHP mkdir怎么用?PHP mkdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: save

 /**
  * Save an uploaded file to a new location.
  *
  * @param   mixed    name of $_FILE input or array of upload data
  * @param   string   new filename
  * @param   string   new directory
  * @param   integer  chmod mask
  * @return  string   full path to new file
  */
 public static function save($file, $filename = NULL, $directory = NULL, $chmod = 0755)
 {
     // Load file data from FILES if not passed as array
     $file = is_array($file) ? $file : $_FILES[$file];
     if ($filename === NULL) {
         // Use the default filename, with a timestamp pre-pended
         $filename = time() . $file['name'];
     }
     // Remove spaces from the filename
     $filename = preg_replace('/\\s+/', '_', $filename);
     if ($directory === NULL) {
         // Use the pre-configured upload directory
         $directory = WWW_ROOT . 'files/';
     }
     // Make sure the directory ends with a slash
     $directory = rtrim($directory, '/') . '/';
     if (!is_dir($directory)) {
         // Create the upload directory
         mkdir($directory, 0777, TRUE);
     }
     //if ( ! is_writable($directory))
     //throw new exception;
     if (is_uploaded_file($file['tmp_name']) and move_uploaded_file($file['tmp_name'], $filename = $directory . $filename)) {
         if ($chmod !== FALSE) {
             // Set permissions on filename
             chmod($filename, $chmod);
         }
         //$all_file_name = array(FILE_INFO => $filename);
         // Return new file path
         return $filename;
     }
     return FALSE;
 }
开发者ID:khaled-saiful-islam,项目名称:zen_v1.0,代码行数:42,代码来源:UploadComponent.php

示例2: execute

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $class_name = ltrim($input->getArgument('class_name'), '\\');
        $namespace_root = $input->getArgument('namespace_root_path');
        $match = [];
        preg_match('/([a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+)\\\\(.+)/', $class_name, $match);
        if ($match) {
            $root_namespace = $match[1];
            $rest_fqcn = $match[2];
            $proxy_filename = $namespace_root . '/ProxyClass/' . str_replace('\\', '/', $rest_fqcn) . '.php';
            $proxy_class_name = $root_namespace . '\\ProxyClass\\' . $rest_fqcn;
            $proxy_class_string = $this->proxyBuilder->build($class_name);
            $file_string = <<<EOF
<?php
// @codingStandardsIgnoreFile

/**
 * This file was generated via php core/scripts/generate-proxy-class.php '{$class_name}' "{$namespace_root}".
 */
{{ proxy_class_string }}
EOF;
            $file_string = str_replace(['{{ proxy_class_name }}', '{{ proxy_class_string }}'], [$proxy_class_name, $proxy_class_string], $file_string);
            mkdir(dirname($proxy_filename), 0775, TRUE);
            file_put_contents($proxy_filename, $file_string);
            $output->writeln(sprintf('Proxy of class %s written to %s', $class_name, $proxy_filename));
        }
    }
开发者ID:318io,项目名称:318-io,代码行数:30,代码来源:GenerateProxyClassCommand.php

示例3: __construct

 function __construct($name)
 {
     $this->folder = TEMP_FOLDER . '/' . $name;
     if (!is_dir($this->folder)) {
         mkdir($this->folder);
     }
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:7,代码来源:ManifestCache.php

示例4: initialize

 /**
  * Initializes this logger.
  *
  * Available options:
  *
  * - file:        The file path or a php wrapper to log messages
  *                You can use any support php wrapper. To write logs to the Apache error log, use php://stderr
  * - format:      The log line format (default to %time% %type% [%priority%] %message%%EOL%)
  * - time_format: The log time strftime format (default to %b %d %H:%M:%S)
  * - dir_mode:    The mode to use when creating a directory (default to 0777)
  * - file_mode:   The mode to use when creating a file (default to 0666)
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean      true, if initialization completes successfully, otherwise false.
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     if (!isset($options['file'])) {
         throw new sfConfigurationException('You must provide a "file" parameter for this logger.');
     }
     if (isset($options['format'])) {
         $this->format = $options['format'];
     }
     if (isset($options['time_format'])) {
         $this->timeFormat = $options['time_format'];
     }
     if (isset($options['type'])) {
         $this->type = $options['type'];
     }
     $dir = dirname($options['file']);
     if (!is_dir($dir)) {
         mkdir($dir, isset($options['dir_mode']) ? $options['dir_mode'] : 0777, true);
     }
     $fileExists = file_exists($options['file']);
     if (!is_writable($dir) || $fileExists && !is_writable($options['file'])) {
         throw new sfFileException(sprintf('Unable to open the log file "%s" for writing.', $options['file']));
     }
     $this->fp = fopen($options['file'], 'a');
     if (!$fileExists) {
         chmod($options['file'], isset($options['file_mode']) ? $options['file_mode'] : 0666);
     }
     return parent::initialize($dispatcher, $options);
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:45,代码来源:sfFileLogger.class.php

示例5: check_for_directory

 function check_for_directory()
 {
     if (!file_exists($this->directory_name)) {
         mkdir($this->directory_name, 0777);
     }
     @chmod($this->directory_name, 0777);
 }
开发者ID:BackupTheBerlios,项目名称:core-svn,代码行数:7,代码来源:cls_upload.php

示例6: __construct

 function __construct(array $config = array())
 {
     $this->_config =& $config;
     // Try to locate app folder.
     if (!isset($config['app_dir'])) {
         $cwd = getcwd();
         while (!is_dir("{$cwd}/app")) {
             if ($cwd == dirname($cwd)) {
                 throw new \LogicException('/app folder not found.');
             }
             $cwd = dirname($cwd);
         }
         $config['app_dir'] = "{$cwd}/app";
     }
     $is_web_request = isset($_SERVER['SERVER_NAME']);
     $config += array('debug' => !$is_web_request || $_SERVER['SERVER_NAME'] == 'localhost', 'register_exception_handler' => $is_web_request, 'register_error_handler' => $is_web_request, 'core_dir' => __DIR__ . '/../..', 'data_dir' => "{$config['app_dir']}/../data");
     $this->exception_handler = new ExceptionHandler($this->debug);
     if ($this->register_exception_handler) {
         set_exception_handler(array($this->exception_handler, 'handle'));
     }
     if ($this->register_error_handler) {
         $this->errorHandler = \Symfony\Component\HttpKernel\Debug\ErrorHandler::register();
     }
     foreach (array($config['data_dir'], "{$config['data_dir']}/cache", "{$config['data_dir']}/logs") as $dir) {
         if (!is_dir($dir)) {
             mkdir($dir);
         }
     }
 }
开发者ID:z7,项目名称:hydra,代码行数:29,代码来源:Core.php

示例7: prepare_dir

 public static function prepare_dir($prefix)
 {
     $config = midcom_baseclasses_components_configuration::get('midcom.helper.filesync', 'config');
     $path = $config->get('filesync_path');
     if (!file_exists($path)) {
         $parent = dirname($path);
         if (!is_writable($parent)) {
             throw new midcom_error("Directory {$parent} is not writable");
         }
         if (!mkdir($path)) {
             throw new midcom_error("Failed to create directory {$path}. Reason: " . $php_errormsg);
         }
     }
     if (substr($path, -1) != '/') {
         $path .= '/';
     }
     $module_dir = "{$path}{$prefix}";
     if (!file_exists($module_dir)) {
         if (!is_writable($path)) {
             throw new midcom_error("Directory {$path} is not writable");
         }
         if (!mkdir($module_dir)) {
             throw new midcom_error("Failed to create directory {$module_dir}. Reason: " . $php_errormsg);
         }
     }
     return "{$module_dir}/";
 }
开发者ID:nemein,项目名称:openpsa,代码行数:27,代码来源:interfaces.php

示例8: createPath

 protected function createPath()
 {
     $fullPath = dirname($this->fullFilePath());
     if (!is_dir($fullPath)) {
         mkdir($fullPath, 0755, true);
     }
 }
开发者ID:railsphp,项目名称:railsphp,代码行数:7,代码来源:NamedBase.php

示例9: makeProjectDir

 protected function makeProjectDir($srcDir = null, $logsDir = null, $cloverXmlPaths = null, $logsDirUnwritable = false, $jsonPathUnwritable = false)
 {
     if ($srcDir !== null && !is_dir($srcDir)) {
         mkdir($srcDir, 0777, true);
     }
     if ($logsDir !== null && !is_dir($logsDir)) {
         mkdir($logsDir, 0777, true);
     }
     if ($cloverXmlPaths !== null) {
         if (is_array($cloverXmlPaths)) {
             foreach ($cloverXmlPaths as $cloverXmlPath) {
                 touch($cloverXmlPath);
             }
         } else {
             touch($cloverXmlPaths);
         }
     }
     if ($logsDirUnwritable) {
         if (file_exists($logsDir)) {
             chmod($logsDir, 0577);
         }
     }
     if ($jsonPathUnwritable) {
         touch($this->jsonPath);
         chmod($this->jsonPath, 0577);
     }
 }
开发者ID:Kreed1346,项目名称:BookSmart,代码行数:27,代码来源:ProjectTestCase.php

示例10: getUrlUploadMultiImages

 public static function getUrlUploadMultiImages($obj, $user_id)
 {
     $url_arr = array();
     $min_size = 1024 * 1000 * 700;
     $max_size = 1024 * 1000 * 1000 * 3.5;
     foreach ($obj["tmp_name"] as $key => $tmp_name) {
         $ext_arr = array('png', 'jpg', 'jpeg', 'bmp');
         $name = StringHelper::filterString($obj['name'][$key]);
         $storeFolder = Yii::getPathOfAlias('webroot') . '/images/' . date('Y-m-d', time()) . '/' . $user_id . '/';
         $pathUrl = 'images/' . date('Y-m-d', time()) . '/' . $user_id . '/' . time() . $name;
         if (!file_exists($storeFolder)) {
             mkdir($storeFolder, 0777, true);
         }
         $tempFile = $obj['tmp_name'][$key];
         $targetFile = $storeFolder . time() . $name;
         $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
         $size = $obj['name']['size'];
         if (in_array($ext, $ext_arr)) {
             if ($size >= $min_size && $size <= $max_size) {
                 if (move_uploaded_file($tempFile, $targetFile)) {
                     array_push($url_arr, $pathUrl);
                 } else {
                     return NULL;
                 }
             } else {
                 return NULL;
             }
         } else {
             return NULL;
         }
     }
     return $url_arr;
 }
开发者ID:huynt57,项目名称:image_chooser,代码行数:33,代码来源:UploadHelper.php

示例11: createSymbolicLink

 public static function createSymbolicLink($rootDir = null)
 {
     IS_MULTI_MODULES || exit('please set is_multi_modules => true');
     $deper = Request::isCli() ? PHP_EOL : '<br />';
     echo "{$deper}**************************create link start!*********************{$deper}";
     echo '|' . str_pad('', 64, ' ', STR_PAD_BOTH) . '|';
     is_null($rootDir) && ($rootDir = ROOT_PATH . DIRECTORY_SEPARATOR . 'web');
     is_dir($rootDir) || mkdir($rootDir, true, 0700);
     //modules_static_path_name
     // 递归遍历目录
     $dirIterator = new \DirectoryIterator(APP_MODULES_PATH);
     foreach ($dirIterator as $file) {
         if (!$file->isDot() && $file->isDir()) {
             $resourceDir = $file->getPathName() . DIRECTORY_SEPARATOR . Config::get('modules_static_path_name');
             if (is_dir($resourceDir)) {
                 $distDir = ROOT_PATH . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . $file->getFilename();
                 $cmd = Request::operatingSystem() ? "mklink /d {$distDir} {$resourceDir}" : "ln -s {$resourceDir} {$distDir}";
                 exec($cmd, $result);
                 $tip = "create link Application [{$file->getFilename()}] result : [" . (is_dir($distDir) ? 'true' : 'false') . "]";
                 $tip = str_pad($tip, 64, ' ', STR_PAD_BOTH);
                 print_r($deper . '|' . $tip . '|');
             }
         }
     }
     echo $deper . '|' . str_pad('', 64, ' ', STR_PAD_BOTH) . '|';
     echo "{$deper}****************************create link end!**********************{$deper}";
 }
开发者ID:phpdn,项目名称:framework,代码行数:27,代码来源:StaticResource.php

示例12: initialize

 /**
  * Initialize the provider
  *
  * @return void
  */
 public function initialize()
 {
     $this->options = array_merge($this->defaultConfig, $this->options);
     date_default_timezone_set($this->options['log.timezone']);
     // Finally, create a formatter
     $formatter = new LineFormatter($this->options['log.outputformat'], $this->options['log.dateformat'], false);
     // Create a new directory
     $logPath = realpath($this->app->config('bono.base.path')) . '/' . $this->options['log.path'];
     if (!is_dir($logPath)) {
         mkdir($logPath, 0755);
     }
     // Create a handler
     $stream = new StreamHandler($logPath . '/' . date($this->options['log.fileformat']) . '.log');
     // Set our formatter
     $stream->setFormatter($formatter);
     // Create LogWriter
     $logger = new LogWriter(array('name' => $this->options['log.name'], 'handlers' => array($stream), 'processors' => array(new WebProcessor())));
     // Bind our logger to Bono Container
     $this->app->container->singleton('log', function ($c) {
         $log = new Log($c['logWriter']);
         $log->setEnabled($c['settings']['log.enabled']);
         $log->setLevel($c['settings']['log.level']);
         $env = $c['environment'];
         $env['slim.log'] = $log;
         return $log;
     });
     // Set the writer
     $this->app->config('log.writer', $logger);
 }
开发者ID:krisanalfa,项目名称:b-comp,代码行数:34,代码来源:LogProvider.php

示例13: indexAction

 public function indexAction()
 {
     $container = $this->container;
     $conn = $this->get('doctrine')->getConnection();
     $dir = $container->getParameter('doctrine_migrations.dir_name');
     if (!file_exists($dir)) {
         mkdir($dir, 0777, true);
     }
     $configuration = new Configuration($conn);
     $configuration->setMigrationsNamespace($container->getParameter('doctrine_migrations.namespace'));
     $configuration->setMigrationsDirectory($dir);
     $configuration->registerMigrationsFromDirectory($dir);
     $configuration->setName($container->getParameter('doctrine_migrations.name'));
     $configuration->setMigrationsTableName($container->getParameter('doctrine_migrations.table_name'));
     $versions = $configuration->getMigrations();
     foreach ($versions as $version) {
         $migration = $version->getMigration();
         if ($migration instanceof ContainerAwareInterface) {
             $migration->setContainer($container);
         }
     }
     $migration = new Migration($configuration);
     $migrated = $migration->migrate();
     // ...
 }
开发者ID:ssone,项目名称:cms-bundle,代码行数:25,代码来源:MigrationController.php

示例14: __construct

 public function __construct($moduleDir, $template, $cache = 2)
 {
     global $app;
     $theme = self::$theme;
     $this->_css = array();
     $this->_js = array('/includes/jquery/jquery.js');
     #~ Setup Debug mode & Template Caching
     $this->debugging = !Live;
     $this->caching = Live ? $cache : false;
     #~ Set the tpl file to display
     $this->_template = $template;
     #~ Set Theme directories
     $this->config_dir = DocRoot . $app->ConfPath;
     $this->template_dir = array(DocRoot . "/themes/{$theme}/templates/{$moduleDir}", DocRoot . "/modules/{$moduleDir}/templates");
     $this->plugins_dir[] = DocRoot . "/themes/{$theme}/plugins";
     #~ Set Writable Theme directories / Create if necessory
     $this->compile_dir = DocRoot . $app->ConfPath . "/tmp/{$theme}_c";
     $this->cache_dir = DocRoot . $app->ConfPath . "/tmp/{$theme}_cache";
     if (!is_dir($this->compile_dir)) {
         mkdir($this->compile_dir);
     }
     if (!is_dir($this->cache_dir)) {
         mkdir($this->cache_dir);
     }
     #~ Every Assignments, if any.
     $this->assign('BaseURL', BaseURL);
     $this->assign('BasePath', BasePath);
     $this->assign('Theme', BasePath . '/themes/' . $theme);
 }
开发者ID:raj47i,项目名称:PHP.Fx,代码行数:29,代码来源:theme.php

示例15: generate

 /**
  * @param  EntityMapping $modelMapping
  * @param  string        $namespace
  * @param  string        $path
  * @param  bool          $override
  * @return void
  */
 public function generate(EntityMapping $modelMapping, $namespace, $path, $override = false)
 {
     $abstractNamespace = $namespace . '\\Base';
     if (!is_dir($path)) {
         mkdir($path, 0777, true);
     }
     $abstractPath = $path . DIRECTORY_SEPARATOR . 'Base';
     if (!is_dir($abstractPath)) {
         mkdir($abstractPath, 0777, true);
     }
     $abstracClassName = 'Abstract' . $modelMapping->getName();
     $classPath = $path . DIRECTORY_SEPARATOR . $modelMapping->getName() . '.php';
     $abstractClassPath = $abstractPath . DIRECTORY_SEPARATOR . $abstracClassName . '.php';
     $nodes = array();
     $nodes = array_merge($nodes, $this->generatePropertyNodes($modelMapping));
     $nodes = array_merge($nodes, $this->generateConstructNodes($modelMapping));
     $nodes = array_merge($nodes, $this->generateMethodNodes($modelMapping));
     $nodes = array_merge($nodes, $this->generateMetadataNodes($modelMapping));
     $nodes = array(new Node\Stmt\Namespace_(new Name($abstractNamespace), array(new Class_('Abstract' . $modelMapping->getName(), array('type' => 16, 'stmts' => $nodes)))));
     $abstractClassCode = $this->phpGenerator->prettyPrint($nodes);
     file_put_contents($abstractClassPath, '<?php' . PHP_EOL . PHP_EOL . $abstractClassCode);
     if (file_exists($classPath) && !$override) {
         return;
     }
     $nodes = array(new Node\Stmt\Namespace_(new Name($namespace), array(new Class_($modelMapping->getName(), array('extends' => new FullyQualified($abstractNamespace . '\\' . $abstracClassName))))));
     $classCode = $this->phpGenerator->prettyPrint($nodes);
     file_put_contents($classPath, '<?php' . PHP_EOL . PHP_EOL . $classCode);
 }
开发者ID:saxulum,项目名称:saxulum-entity-generator,代码行数:35,代码来源:EntityGenerator.php


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