<?php
/*
* jQuery File Upload Plugin PHP Class 6.1.2
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
class UploadHandler
{
protected $options;
// PHP File Upload error message codes:
// http://php.net/manual/en/features.file-upload.errors.php
protected $error_messages = array(
1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini',
2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
3 => 'The uploaded file was only partially uploaded',
4 => 'No file was uploaded',
6 => 'Missing a temporary folder',
7 => 'Failed to write file to disk',
8 => 'A PHP extension stopped the file upload',
'post_max_size' => 'The uploaded file exceeds the post_max_size directive in php.ini',
'max_file_size' => 'File is too big',
'min_file_size' => 'File is too small',
'accept_file_types' => 'Filetype not allowed',
'max_number_of_files' => 'Maximum number of files exceeded',
'max_width' => 'Image exceeds maximum width',
'min_width' => 'Image requires a minimum width',
'max_height' => 'Image exceeds maximum height',
'min_height' => 'Image requires a minimum height'
);
function __construct($options = null, $initialize = true) {
$this->options = array(
'script_url' => $this->get_full_url().'/',
'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).'/files/',
'upload_url' => $this->get_full_url().'/files/',
'user_dirs' => false,
'mkdir_mode' => 0755,
'param_name' => 'files',
// Set the following option to 'POST', if your server does not support
// DELETE requests. This is a parameter sent to the client:
'delete_type' => 'DELETE',
'access_control_allow_origin' => '*',
'access_control_allow_credentials' => false,
'access_control_allow_methods' => array(
'OPTIONS',
'HEAD',
'GET',
'POST',
'PUT',
'PATCH',
'DELETE'
),
'access_control_allow_headers' => array(
'Content-Type',
'Content-Range',
'Content-Disposition'
),
// Enable to provide file downloads via GET requests to the PHP script:
'download_via_php' => false,
// Defines which files can be displayed inline when downloaded:
'inline_file_types' => '/\.(gif|jpe?g|png)$/i',
// Defines which files (based on their names) are accepted for upload:
'accept_file_types' => '/.+$/i',
// The php.ini settings upload_max_filesize and post_max_size
// take precedence over the following max_file_size setting:
'max_file_size' => null,
'min_file_size' => 1,
// The maximum number of files for the upload directory:
'max_number_of_files' => null,
// Image resolution restrictions:
'max_width' => null,
'max_height' => null,
'min_width' => 1,
'min_height' => 1,
// Set the following option to false to enable resumable uploads:
'discard_aborted_uploads' => true,
// Set to true to rotate images based on EXIF meta data, if available:
'orient_image' => false,
'image_versions' => array(
// Uncomment the following version to restrict the size of
// uploaded images:
/*
'' => array(
'max_width' => 1920,
'max_height' => 1200,
'jpeg_quality' => 95
),
*/
// Uncomment the following to create medium sized images:
/*
'medium' => array(
'max_width' => 800,
'max_height' => 600,
'jpeg_quality' => 80
),
*/
'thumbnail' => array(
'max_width' => 80,
'max_height' => 80
)
)
);
if ($options) {
$this->options = array_merge($this->options, $options);
}
if ($initialize) {
$this->initialize();
}
}
protected function initialize() {
switch ($_SERVER['REQUEST_METHOD']) {
case 'OPTIONS':
case 'HEAD':
$this->head();
break;
case 'GET':
$this->get();
break;
case 'PATCH':
case 'PUT':
case 'POST':
$this->post();
break;
case 'DELETE':
$this->delete();
break;
default:
$this->header('HTTP/1.1 405 Method Not Allowed');
}
}
protected function get_full_url() {
$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
return
($https ? 'https://' : 'http://').
(!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : '').
(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].
($https && $_SERVER['SERVER_PORT'] === 443 ||
$_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))).
substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
}
protected function get_user_id() {
@session_start();
return session_id();
}
protected function get_user_path() {
if ($this->options['user_dirs']) {
return $this->get_user_id().'/';
}
return '';
}
protected function get_upload_path($file_name = null, $version = null) {
$file_name = $file_name ? $file_name : '';
$version_path = empty($version) ? '' : $version.'/';
return $this->options['upload_dir'].$this->get_user_path()
.$version_path.$file_name;
}
protected function get_query_separator($url) {
return strpos($url, '?') === false ? '?' : '&';
}
protected function get_download_url($file_name, $version = null) {
if ($this->options['download_via_php']) {
$url = $this->options['script_url']
.$this->get_query_separator($this->options['script_url'])
.'file='.rawurlencode($file_name);
if ($version) {
$url .= '&version='.rawurlencode($version);
}
return $url.'&download=1';
}
$version_path = empty($version) ? '' : rawurlencode($version).'/';
return $this->options['upload_url'].$this->get_user_path()
.$version_path.rawurlencode($file_name);
}
protected function set_file_delete_properties($file) {
$file->delete_url = $this->options['script_url']
.$this->get_query_separator($this->options['script_url'])
.'file='.rawurlencode($file->name);
$file->delete_type = $this->options['delete_type'];
if ($file->delete_type !== 'DELETE') {
$file->delete_url .= '&_method=DELETE';
}
if ($this->options['access_control_allow_credentials']) {
$file->delete_with_credentials = true;
}
}
// Fix for overflowing signed 32 bit integers,
// works for sizes up to 2^32-1 bytes (4 GiB - 1):
protected function fix_integer_overflow($size) {
if ($size < 0) {
$size += 2.0 * (PHP_INT_MAX + 1);
}
return $size;
}
protected function get_file_size($file_
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
世界贸易可视化 (3085个子文件)
00050375cc204b5bfd03aa73794de1eaa2c7fa 2KB
001a86e22336a538ccf8c086434c9d35b1ec38 3KB
0022c4e0c9dd61772c03307d64da6db95ecbe0 149B
002e6d8cf3f9794eb0d0191a2d244f535f4351 56B
00452883cce6a2cf77cdc323717dd9212f39bc 198B
00727fdea0145fea9381cf5fe7c46d2e8b4191 4KB
007e575793d837aa089398629ad86907463c94 92B
009c0d9b109d0a38ec55cf37030d1e4f3e9cd4 129B
00e1d1a108933ae9362903c4f4624ab82e3c8e 138B
0103c0340cefc2064557686fc84f30c1b2f204 2KB
0134e8fdcea91f9210e1ea11125f13808493bc 1KB
0140cff67999e0b6daf269723e019335f5fee6 4KB
015f7488dab689ef8fcdc751185114a3d3d02b 402B
016e12e8628e512813db5ae6a5e4f27c22b140 49B
0190218c15869fc273b2b5b8e476405bcdab97 3KB
01cb84487c7f983c4d4e15f6d171990521519e 216B
028fb343980ff7bb5c6ca483bac58ddc780a8a 194B
02ba428eaaaa39682a6cee9791ce3b8cd6b976 3KB
02eff860fa1c87debe4c78d373d4400ac7f3bc 618B
02f4d274423fb81fc2a6344610e992ba9de856 443B
0306c51586d66eb6f338bffb113ba714f6d441 146KB
030af26bd1e0187abd97fb90b0ea9f3fd58e92 312B
03115a8ea3f7473a8a64ac7a0a415c4f028fd5 212B
032d576df5b75118a86832f9ad5bab55f26d32 46B
036e901680afbd857f34a543f05643927b45ab 497B
03c47e2f32dd4697dadb7eeafdf6652fe94454 3KB
03cecb240a9f3a4654d9d40e8514d1c2894525 2KB
03cf4c6431c8fda0c9945a15bfc5148905d73a 53B
03d41ddcb94c73db735735b05f09f41c19c986 58B
04be66318b019fd287b384c2e83d41b81d61af 91B
04e50f32b668f75abd797a84b09d2d8a261064 1KB
04fef761185e3dd9008f194100f468aaae41bb 1KB
05262bb386bbcf798dc35c73269bf608785836 128B
052b066e0b36900d6f085e28d1c210144f05e3 187B
0536286f3081c6c0646817037faf5446e3547d 40B
056781fe2ece1a4c6f5cf3544d58a1f2d6a21e 212B
05706456f1d8ce674c487c0e328f7a0f96819e 138B
05a7ceb46e1b49f3ad56703a1138fbffe70d42 176B
05c5ebf2dcf5db3c2b0330500b94e90162f7ba 104B
05d194b0189157ae154ba2ff446e50b951d3c1 617B
05ee4221fa3672b7e8c2e1d55358ed3eb0ba8e 45B
05f9db2a09c1964d72b777936d407396108cb2 2KB
065db50f08fdbcb0fed020e6641b7ba0c52007 46B
066730d840a3c47cb30e2311b973f4f7acb8a6 348B
066820a18d0688d22ee8d853679eed34ce1ab2 228B
068f7c6f169be91d67f7b0d0b02fea706afa5f 6KB
06e48b9ff0fe1252bcc2f7622599b88ccdfac6 928B
0703f179f3ea80529899eb054ee7d7704f6cbb 425B
073dd17d2a68753ab79829aab100166f893f43 303B
074c86233a11b1ab79f7afc2df0f29079d0467 45B
077663bbd5c7cf3d458dc332365c6774a101b8 124B
07afe518f88fad3d87c67d5e7826774a6ef64b 1KB
07ff5c3be5ddfd3ae343544dcebea72681d57c 45B
08089a5f99fdcbcf1c05a60185f66038ad9af2 156B
08098408d3b87823bd54137ee06e4fb92610ac 897B
081a98c451d674e4b59642dd0d1095a921f0a7 2KB
08638dacc4fcb79adeec5d0824c668cb4ef063 135B
08ae6e938bfa02e2a403eeb2bbbc69c1872fd4 220B
08f8fc94c307aeb90d17c4401ad0e33629ca3c 121B
092b2d5317cf822d46f073228c76960094aa19 92B
096bbb20f4c73f06376459ccd79b105b51aeb1 388B
099cc2295a1bf02c7fa08d49141e1433f04489 159B
09a7cd39e514823a40495ec088901c2f9d1ca4 2KB
09daa560ac9cdf8b7544a977e247b1121f957a 165B
0a12490789d555879974fb89b8170e89549388 5KB
0a3ab99c349747cf48151e88663c4f5f57be0c 150B
0a61961f7d10ae0bff25e9d31f319886794b83 111B
0a909450b709716b9fa5005fa48f0747c84280 138B
0a9d62830dd78cbd9551fe46add7e81d5b8587 62B
0ab6a73d17d259b0dc37a809c6d9d8ba34e440 158B
0abee13b23a1a96191e3ba20b2257ee3888939 24KB
0b03dee5e6a7c8c39e89a7fd3cad4cd4367d1f 149B
0b07d3218cbfed6fcce6fe67d1fb095bf0e0ad 4KB
0b3d70329aa9d8ca115e5e8af528185d4d07f6 160B
0b3f00a113b4a4b1bd6542ec2e963439c35349 4KB
0b775dacdff9ebb52f5fc20057a40dc48714fb 90B
0b890f1f43caa9939d6a0b5b42bcb69745f0eb 123B
0bb6d786adadd5d100ba54bb604beb93d16d5b 188B
0bf8a4282c2899d7018d8a979bc5cea474d4a6 47KB
0c49d1da41e96bac3e49c84ec1b988294fba78 1KB
0c55dfd5d4cd500d59ba7ec50179fca719e6d2 160B
0c807808b853d556e10bc6328200534e60780f 723B
0c807c5f92daa7c93b985b2fcb11c1a057ce62 1KB
0cbd9b65db14f8447ad4d95db8aa5571de9572 5KB
0cd3fc6eddab4d52f73fdf30679ff8e276c921 45B
0d29131aed163207918e5ef86a0854b82fdec9 160B
0d67349ec3ef618c11766686b9cec94bc4e216 294B
0d6934af6c28ba35414f3ec657015e1a9ffed6 149B
0db194a5b4304ccf28a91f37a8299ca759fe3e 121B
0dbad858fcbf9b06edb7bff74cb8feecaa8b71 35KB
0e396d7b1bac38d005309f3e345854b23e7e4e 6KB
0e582058748984e3881f4751635ba3cc0fd624 89B
0e6c8348f012132866ea42f970b0d939843378 216B
0e8629af924cffb39edf27b0db6f62eef78cac 445B
0ea3b3e64719c9cb29125bd79c577b83a2faf4 55B
0f4bfaa86e5fa710128fb807afc593f311e58c 149B
0f80a33f2e80d7b49945ad3ae475520000d7d9 1KB
0f8299e0227450961137922bffefbb2107a74b 46B
0fce565db0c8a362ef82635552ae90e5c1cedd 1KB
0fffbcc2ed339ae2d73a209c894421a722f966 542B
共 3085 条
- 1
- 2
- 3
- 4
- 5
- 6
- 31
资源评论
pengli_123
- 粉丝: 3
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 目标检测-手机屏幕表面缺陷检测数据集-1200张图-+对应VOC-COCO-YOLO三种格式标签+数据集划分脚本
- 「天若有情 」深情版--天下万般兵刃 唯有过往伤人最深.mp3
- 123456daWDdwD
- 用友U810.1数据库字典-只需要1积分
- 基于opencv和numpy的customtkinter图像处理工具
- 最新1.8JDK的PostgreSQL JDBC 驱动包
- stlink驱动+J-Link驱动+ST-LINK utility工具
- 项目实战-Python基于KMeans算法进行文本聚类项目实战.zip
- 弹幕视频网站 java源代码毕业设计毕业论文
- 多用户博客个人网站java源代码毕业设计毕业论文
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功