|
1 | 1 | <?php
|
2 | 2 | /*
|
3 |
| - * jQuery File Upload Plugin PHP Class 5.13 |
| 3 | + * jQuery File Upload Plugin PHP Class 5.13.1 |
4 | 4 | * https://github.com/blueimp/jQuery-File-Upload
|
5 | 5 | *
|
6 | 6 | * Copyright 2010, Sebastian Tschan
|
@@ -104,19 +104,23 @@ protected function set_file_delete_url($file) {
|
104 | 104 | }
|
105 | 105 | }
|
106 | 106 |
|
107 |
| - protected function get_file_size($file_path, $clear_stat_cache = false) { |
108 |
| - if ($clear_stat_cache) { |
109 |
| - clearstatcache(); |
110 |
| - } |
111 |
| - $size = filesize($file_path); |
| 107 | + // Fix for overflowing signed 32 bit integers, |
| 108 | + // works for sizes up to 2^32-1 bytes (4 GiB - 1): |
| 109 | + protected function fix_integer_overflow($size) { |
112 | 110 | if ($size < 0) {
|
113 |
| - // Fix for overflowing signed 32 bit integers, |
114 |
| - // works for files up to 2^32-1 bytes (4 GiB - 1) in size: |
115 | 111 | $size += 2.0 * (PHP_INT_MAX + 1);
|
116 | 112 | }
|
117 | 113 | return $size;
|
118 | 114 | }
|
119 | 115 |
|
| 116 | + protected function get_file_size($file_path, $clear_stat_cache = false) { |
| 117 | + if ($clear_stat_cache) { |
| 118 | + clearstatcache(); |
| 119 | + } |
| 120 | + return $this->fix_integer_overflow(filesize($file_path)); |
| 121 | + |
| 122 | + } |
| 123 | + |
120 | 124 | protected function get_file_object($file_name) {
|
121 | 125 | $file_path = $this->options['upload_dir'].$file_name;
|
122 | 126 | if (is_file($file_path) && $file_name[0] !== '.') {
|
@@ -336,7 +340,7 @@ protected function orient_image($file_path) {
|
336 | 340 | protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null) {
|
337 | 341 | $file = new stdClass();
|
338 | 342 | $file->name = $this->trim_file_name($name, $type, $index);
|
339 |
| - $file->size = intval($size); |
| 343 | + $file->size = $this->fix_integer_overflow(intval($size)); |
340 | 344 | $file->type = $type;
|
341 | 345 | if ($this->validate($uploaded_file, $file, $error, $index)) {
|
342 | 346 | $this->handle_form_data($file, $index);
|
|
0 commit comments