|
1 | 1 | <?php
|
2 | 2 | /*
|
3 |
| - * jQuery File Upload Plugin PHP Class 5.10 |
| 3 | + * jQuery File Upload Plugin PHP Class 5.11 |
4 | 4 | * https://github.com/blueimp/jQuery-File-Upload
|
5 | 5 | *
|
6 | 6 | * Copyright 2010, Sebastian Tschan
|
@@ -28,7 +28,13 @@ function __construct($options=null) {
|
28 | 28 | 'max_file_size' => null,
|
29 | 29 | 'min_file_size' => 1,
|
30 | 30 | 'accept_file_types' => '/.+$/i',
|
| 31 | + // The maximum number of files for the upload directory: |
31 | 32 | 'max_number_of_files' => null,
|
| 33 | + // Image resolution restrictions: |
| 34 | + 'max_width' => null, |
| 35 | + 'max_height' => null, |
| 36 | + 'min_width' => 1, |
| 37 | + 'min_height' => 1, |
32 | 38 | // Set the following option to false to enable resumable uploads:
|
33 | 39 | 'discard_aborted_uploads' => true,
|
34 | 40 | // Set to true to rotate images based on EXIF meta data, if available:
|
@@ -201,6 +207,19 @@ protected function validate($uploaded_file, $file, $error, $index) {
|
201 | 207 | $file->error = 'maxNumberOfFiles';
|
202 | 208 | return false;
|
203 | 209 | }
|
| 210 | + list($img_width, $img_height) = @getimagesize($uploaded_file); |
| 211 | + if (is_int($img_width)) { |
| 212 | + if ($this->options['max_width'] && $img_width > $this->options['max_width'] || |
| 213 | + $this->options['max_height'] && $img_height > $this->options['max_height']) { |
| 214 | + $file->error = 'maxResolution'; |
| 215 | + return false; |
| 216 | + } |
| 217 | + if ($this->options['min_width'] && $img_width < $this->options['min_width'] || |
| 218 | + $this->options['min_height'] && $img_height < $this->options['min_height']) { |
| 219 | + $file->error = 'minResolution'; |
| 220 | + return false; |
| 221 | + } |
| 222 | + } |
204 | 223 | return true;
|
205 | 224 | }
|
206 | 225 |
|
|
0 commit comments