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


PHP UploadedFile::create方法代码示例

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


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

示例1: buildMap

 /**
  * Recursively builds the map of UploadedFile instances.
  *
  * @param array $files
  * @param array $destination
  *
  * @return void
  */
 private static function buildMap(array $files, array &$destination)
 {
     foreach ($files as $structure) {
         foreach ($structure as $key => $value) {
             $subFiles = [];
             foreach ($files as $uploadKey => $data) {
                 $subFiles[$uploadKey] = $data[$key];
             }
             if (is_array($value)) {
                 $destination[$key] = [];
                 self::buildMap($subFiles, $destination[$key]);
             } else {
                 $destination[$key] = UploadedFile::create($subFiles);
             }
         }
         // Only one of the entries was needed to get the structure.
         break;
     }
 }
开发者ID:brick,项目名称:http,代码行数:27,代码来源:UploadedFileMap.php

示例2: process_request_vars

 protected function process_request_vars($params)
 {
     # throw an exception if the max post size is reached
     if (array_key_exists('CONTENT_LENGTH', $_SERVER) && !empty($_POST)) {
         $pms = ini_get('post_max_size');
         $mul = substr($pms, -1);
         $mul = $mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1));
         if ($_SERVER['CONTENT_LENGTH'] > $mul * (int) $pms && $pms) {
             throw new MaxPostSizeExceeded("The posted data was too large. The maximum post size is: {$pms}.");
         }
     }
     # add request to params and make sure magic quotes are dealt with
     unset($_POST['MAX_FILE_SIZE']);
     unset($_GET['MAX_FILE_SIZE']);
     $gpc = get_magic_quotes_gpc() == 1;
     foreach (array($_GET, $_POST) as $R) {
         foreach ($R as $k => $v) {
             if (!isset($params[$k])) {
                 if (is_array($v)) {
                     $params[$k] = array();
                     foreach ($v as $k2 => $v2) {
                         $params[$k][$k2] = $gpc && !is_array($v2) ? stripslashes($v2) : $v2;
                     }
                 } else {
                     $params[$k] = $gpc ? stripslashes($v) : $v;
                 }
             }
         }
     }
     # add files to params
     foreach ($_FILES as $k => $v) {
         if (!isset($params[$k])) {
             try {
                 $uploaded_file = UploadedFile::create($v);
             } catch (UpoadedFileException $e) {
                 $uploaded_file = false;
             }
             $params[$k] = $uploaded_file;
         }
     }
     return $params;
 }
开发者ID:brysonian,项目名称:Vicious,代码行数:42,代码来源:Router.php

示例3: handle_url

 /**
  * find the best map include the right classes and
  * start hand off to the controller
  */
 static function handle_url($url)
 {
     if (defined('DEBUG') && DEBUG) {
         error_log("Begin processing: {$url}");
         $start = microtime(true);
     }
     $u = Usher::get_instance();
     # routing is here
     $params = $u->match_url($url);
     # if no match was found, show the error
     if (!$params) {
         throw new NoValidMapping("No mapping was found for "{$url}".");
     }
     # add request to params and make sure magic quotes are dealt with
     unset($_POST['MAX_FILE_SIZE']);
     unset($_GET['MAX_FILE_SIZE']);
     foreach ($_POST as $k => $v) {
         if (!array_key_exists($k, $params)) {
             $gpc = get_magic_quotes_gpc() == 1;
             if (is_array($v)) {
                 $params[$k] = array();
                 foreach ($v as $k2 => $v2) {
                     $params[$k][$k2] = $gpc && !is_array($v2) ? stripslashes($v2) : $v2;
                 }
             } else {
                 $params[$k] = $gpc ? stripslashes($v) : $v;
             }
         }
     }
     foreach ($_GET as $k => $v) {
         if (!array_key_exists($k, $params)) {
             $gpc = get_magic_quotes_gpc() == 1;
             if (is_array($v)) {
                 $params[$k] = array();
                 foreach ($v as $k2 => $v2) {
                     $params[$k][$k2] = $gpc && !is_array($v2) ? stripslashes($v2) : $v2;
                 }
             } else {
                 $params[$k] = $gpc ? stripslashes($v) : $v;
             }
         }
     }
     # add files to params and make sure magic quotes are dealt with
     foreach ($_FILES as $k => $v) {
         if (!array_key_exists($k, $params)) {
             $params[$k] = array();
         }
         $params[$k] = array_merge($params[$k], UploadedFile::create($v));
     }
     # save the params
     self::$params = $params;
     # get the controller name
     #$cname = preg_replace('/(?:^|_)([a-zA-Z])/e', "strtoupper('\\1')", $params['controller']);
     $cname = class_name($params['controller']);
     $cname = ucfirst($cname . 'Controller');
     # make sure the name is a valid class name
     if (preg_match('|[^a-zA-Z_]|', $cname) > 0 || preg_match('|^[^a-zA-Z_]|', $cname) > 0) {
         throw new UnknownController("{$cname} is not a valid controller.");
     }
     if (defined('DEBUG') && DEBUG) {
         error_log("Controller found in " . (microtime(true) - $start) . " seconds.");
     }
     # make an instance of the controller class
     self::$controller = new $cname();
     # set the method name
     $action = $params['action'];
     # tell the controller to execute the action
     self::$controller->execute($action);
     # log exec time
     if (defined('DEBUG') && DEBUG) {
         $end = microtime(true);
         error_log("Executed in " . ($end - $start) . " seconds.");
     }
 }
开发者ID:brysonian,项目名称:Saint,代码行数:78,代码来源:Usher.php


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