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


PHP UploadHandler::files方法代码示例

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


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

示例1: processUploads

	/**
	 * Processes server and $_FILE info relating to uploads to produce usable info. Assigns all gathered data to class variables which are accessible via public methods.
	 *
	 * @return void
	 * @throws UploadHandlerProcessPostSizeException If the posted data size exceeds the maximum post size defined by php configuration
	 * @throws UploadHandlerProcessNoInputException If no files were uploaded
	 */
	public static function processUploads()
	{
		if (self::$_processed) {
			return;
		}

		self::$_processed = true;

		self::$files = array();

		if (self::$contentLength >= self::$maxPostSize) {
			//	post length exceeds maximum post length ini directive - impossible for php to parse uploaded files because $_FILES is empty
			throw new UploadHandlerProcessPostSizeException(sprintf(self::$i18n['UPLOADHANDLER_ERR_PROCESS_POST_SIZE'], self::$contentLength, self::$maxPostSize));
		}

		if (empty($_FILES)) {
			//	no files uploaded
			throw new UploadHandlerProcessNoInputException(self::$i18n['UPLOADHANDLER_ERR_PROCESS_NO_INPUT']);
		}

		foreach ($_FILES as $fieldName => $field) {

			if (is_array($field['name'])) {
				//	input field that uses [] in it's name

				self::$files[$fieldName] = array();

				foreach ($field['name'] as $index => $ignoreThisValue) {
					$name = $field['name'][$index];
					$type = $field['type'][$index];
					$tmp_name = $field['tmp_name'][$index];
					$error = intval($field['error'][$index]);
					$size = intval($field['size'][$index]);

					$file = new UploadHandlerFile($fieldName, $name, $type, $tmp_name, $error, $size);

					self::$files[$fieldName][] = $file;
				}

			} else {
				//	single input field
				$name = $field['name'];
				$type = $field['type'];
				$tmp_name = $field['tmp_name'];
				$error = intval($field['error']);
				$size = intval($field['size']);

				$file = new UploadHandlerFile($fieldName, $name, $type, $tmp_name, $error, $size);

				self::$files[$fieldName] = array($file);
			}
		}
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:60,代码来源:uploadhandler.php


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