本文整理汇总了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);
}
}
}