update fileUploader to 9.21.0
This commit is contained in:
@@ -34,7 +34,7 @@ class Uploader extends UploadHandler
|
|||||||
* https://blueimp.net
|
* https://blueimp.net
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license:
|
* Licensed under the MIT license:
|
||||||
* http://www.opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class UploadHandler
|
class UploadHandler
|
||||||
@@ -67,12 +67,13 @@ class UploadHandler
|
|||||||
|
|
||||||
protected $image_objects = array();
|
protected $image_objects = array();
|
||||||
|
|
||||||
function __construct($options = null, $initialize = true, $error_messages = null) {
|
public function __construct($options = null, $initialize = true, $error_messages = null) {
|
||||||
$this->response = array();
|
$this->response = array();
|
||||||
$this->options = array(
|
$this->options = array(
|
||||||
'script_url' => $this->get_full_url().'/'.basename($this->get_server_var('SCRIPT_NAME')),
|
'script_url' => $this->get_full_url().'/'.$this->basename($this->get_server_var('SCRIPT_NAME')),
|
||||||
'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/files/',
|
'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/files/',
|
||||||
'upload_url' => $this->get_full_url().'/files/',
|
'upload_url' => $this->get_full_url().'/files/',
|
||||||
|
'input_stream' => 'php://input',
|
||||||
'user_dirs' => false,
|
'user_dirs' => false,
|
||||||
'mkdir_mode' => 0755,
|
'mkdir_mode' => 0755,
|
||||||
'param_name' => 'files',
|
'param_name' => 'files',
|
||||||
@@ -157,12 +158,16 @@ class UploadHandler
|
|||||||
// Command or path for to the ImageMagick identify binary:
|
// Command or path for to the ImageMagick identify binary:
|
||||||
'identify_bin' => 'identify',
|
'identify_bin' => 'identify',
|
||||||
'image_versions' => array(
|
'image_versions' => array(
|
||||||
// The empty image version key defines options for the original image:
|
// The empty image version key defines options for the original image.
|
||||||
|
// Keep in mind: these image manipulations are inherited by all other image versions from this point onwards.
|
||||||
|
// Also note that the property 'no_cache' is not inherited, since it's not a manipulation.
|
||||||
'' => array(
|
'' => array(
|
||||||
// Automatically rotate images based on EXIF meta data:
|
// Automatically rotate images based on EXIF meta data:
|
||||||
'auto_orient' => true
|
'auto_orient' => true
|
||||||
),
|
),
|
||||||
// Uncomment the following to create medium sized images:
|
// You can add arrays to generate different versions.
|
||||||
|
// The name of the key is the name of the version (example: 'medium').
|
||||||
|
// the array contains the options to apply.
|
||||||
/*
|
/*
|
||||||
'medium' => array(
|
'medium' => array(
|
||||||
'max_width' => 800,
|
'max_width' => 800,
|
||||||
@@ -179,9 +184,13 @@ class UploadHandler
|
|||||||
//'upload_url' => $this->get_full_url().'/thumb/',
|
//'upload_url' => $this->get_full_url().'/thumb/',
|
||||||
// Uncomment the following to force the max
|
// Uncomment the following to force the max
|
||||||
// dimensions and e.g. create square thumbnails:
|
// dimensions and e.g. create square thumbnails:
|
||||||
|
// 'auto_orient' => true,
|
||||||
// 'crop' => true,
|
// 'crop' => true,
|
||||||
'max_width' => 80,
|
// 'jpeg_quality' => 70,
|
||||||
'max_height' => 80
|
// 'no_cache' => true, (there's a caching option, but this remembers thumbnail sizes from a previous action!)
|
||||||
|
// 'strip' => true, (this strips EXIF tags, such as geolocation)
|
||||||
|
'max_width' => 80, // either specify width, or set to 0. Then width is automatically adjusted - keeping aspect ratio to a specified max_height.
|
||||||
|
'max_height' => 80 // either specify height, or set to 0. Then height is automatically adjusted - keeping aspect ratio to a specified max_width.
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'print_response' => true
|
'print_response' => true
|
||||||
@@ -373,9 +382,10 @@ class UploadHandler
|
|||||||
$this->error_messages[$error] : $error;
|
$this->error_messages[$error] : $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_config_bytes($val) {
|
public function get_config_bytes($val) {
|
||||||
$val = trim($val);
|
$val = trim($val);
|
||||||
$last = strtolower($val[strlen($val)-1]);
|
$last = strtolower($val[strlen($val)-1]);
|
||||||
|
$val = (int)$val;
|
||||||
switch ($last) {
|
switch ($last) {
|
||||||
case 'g':
|
case 'g':
|
||||||
$val *= 1024;
|
$val *= 1024;
|
||||||
@@ -543,7 +553,7 @@ class UploadHandler
|
|||||||
// Remove path information and dots around the filename, to prevent uploading
|
// Remove path information and dots around the filename, to prevent uploading
|
||||||
// into different directories or replacing hidden system files.
|
// into different directories or replacing hidden system files.
|
||||||
// Also remove control characters and spaces (\x00..\x20) around the filename:
|
// Also remove control characters and spaces (\x00..\x20) around the filename:
|
||||||
$name = trim(basename(stripslashes($name)), ".\x00..\x20");
|
$name = trim($this->basename(stripslashes($name)), ".\x00..\x20");
|
||||||
// Use a timestamp for empty filenames:
|
// Use a timestamp for empty filenames:
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
$name = str_replace('.', '-', microtime(true));
|
$name = str_replace('.', '-', microtime(true));
|
||||||
@@ -888,21 +898,31 @@ class UploadHandler
|
|||||||
if (!empty($options['auto_orient'])) {
|
if (!empty($options['auto_orient'])) {
|
||||||
$image_oriented = $this->imagick_orient_image($image);
|
$image_oriented = $this->imagick_orient_image($image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$image_resize = false;
|
||||||
$new_width = $max_width = $img_width = $image->getImageWidth();
|
$new_width = $max_width = $img_width = $image->getImageWidth();
|
||||||
$new_height = $max_height = $img_height = $image->getImageHeight();
|
$new_height = $max_height = $img_height = $image->getImageHeight();
|
||||||
if (!empty($options['max_width'])) {
|
|
||||||
|
// use isset(). User might be setting max_width = 0 (auto in regular resizing). Value 0 would be considered empty when you use empty()
|
||||||
|
if (isset($options['max_width'])) {
|
||||||
|
$image_resize = true;
|
||||||
$new_width = $max_width = $options['max_width'];
|
$new_width = $max_width = $options['max_width'];
|
||||||
}
|
}
|
||||||
if (!empty($options['max_height'])) {
|
if (isset($options['max_height'])) {
|
||||||
|
$image_resize = true;
|
||||||
$new_height = $max_height = $options['max_height'];
|
$new_height = $max_height = $options['max_height'];
|
||||||
}
|
}
|
||||||
if (!($image_oriented || $max_width < $img_width || $max_height < $img_height)) {
|
|
||||||
|
$image_strip = (isset($options['strip']) ? $options['strip'] : false);
|
||||||
|
|
||||||
|
if ( !$image_oriented && ($max_width >= $img_width) && ($max_height >= $img_height) && !$image_strip && empty($options["jpeg_quality"]) ) {
|
||||||
if ($file_path !== $new_file_path) {
|
if ($file_path !== $new_file_path) {
|
||||||
return copy($file_path, $new_file_path);
|
return copy($file_path, $new_file_path);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$crop = !empty($options['crop']);
|
$crop = (isset($options['crop']) ? $options['crop'] : false);
|
||||||
|
|
||||||
if ($crop) {
|
if ($crop) {
|
||||||
$x = 0;
|
$x = 0;
|
||||||
$y = 0;
|
$y = 0;
|
||||||
@@ -942,7 +962,7 @@ class UploadHandler
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!empty($options['strip'])) {
|
if ( $image_strip ) {
|
||||||
$image->stripImage();
|
$image->stripImage();
|
||||||
}
|
}
|
||||||
return $success && $image->writeImage($new_file_path);
|
return $success && $image->writeImage($new_file_path);
|
||||||
@@ -1109,7 +1129,7 @@ class UploadHandler
|
|||||||
// Non-multipart uploads (PUT method support)
|
// Non-multipart uploads (PUT method support)
|
||||||
file_put_contents(
|
file_put_contents(
|
||||||
$file_path,
|
$file_path,
|
||||||
fopen('php://input', 'r'),
|
fopen($this->options['input_stream'], 'r'),
|
||||||
$append_file ? FILE_APPEND : 0
|
$append_file ? FILE_APPEND : 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1176,7 +1196,7 @@ class UploadHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function get_version_param() {
|
protected function get_version_param() {
|
||||||
return basename(stripslashes($this->get_query_param('version')));
|
return $this->basename(stripslashes($this->get_query_param('version')));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function get_singular_param_name() {
|
protected function get_singular_param_name() {
|
||||||
@@ -1185,7 +1205,7 @@ class UploadHandler
|
|||||||
|
|
||||||
protected function get_file_name_param() {
|
protected function get_file_name_param() {
|
||||||
$name = $this->get_singular_param_name();
|
$name = $this->get_singular_param_name();
|
||||||
return basename(stripslashes($this->get_query_param($name)));
|
return $this->basename(stripslashes($this->get_query_param($name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function get_file_names_params() {
|
protected function get_file_names_params() {
|
||||||
@@ -1194,7 +1214,7 @@ class UploadHandler
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
foreach ($params as $key => $value) {
|
foreach ($params as $key => $value) {
|
||||||
$params[$key] = basename(stripslashes($value));
|
$params[$key] = $this->basename(stripslashes($value));
|
||||||
}
|
}
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
@@ -1411,4 +1431,8 @@ class UploadHandler
|
|||||||
return $this->generate_response($response, $print_response);
|
return $this->generate_response($response, $print_response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function basename($filepath, $suffix = null) {
|
||||||
|
$splited = preg_split('/\//', rtrim ($filepath, '/ '));
|
||||||
|
return substr(basename('X'.$splited[count($splited)-1], $suffix), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ oSpot.pageInit = function(asHash)
|
|||||||
done: function (e, data) {
|
done: function (e, data) {
|
||||||
var $Status = $('#status');
|
var $Status = $('#status');
|
||||||
$.each(data.result.files, function(iKey, oFile) {
|
$.each(data.result.files, function(iKey, oFile) {
|
||||||
$Status.append($('<p>').text(oFile.name+" uploaded succesfully"));
|
var sMsg = ('error' in oFile)?oFile.error:(oFile.name+" uploaded succesfully");
|
||||||
|
$Status.append($('<p>').text(sMsg));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
progressall: function (e, data) {
|
progressall: function (e, data) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user