|
1 | 1 | <?php |
2 | 2 | /* |
3 | | - * jQuery File Upload Plugin PHP Class 6.8.1 |
| 3 | + * jQuery File Upload Plugin PHP Class 6.9.0 |
4 | 4 | * https://github.com/blueimp/jQuery-File-Upload |
5 | 5 | * |
6 | 6 | * Copyright 2010, Sebastian Tschan |
@@ -225,7 +225,8 @@ protected function get_download_url($file_name, $version = null, $direct = false |
225 | 225 | protected function set_additional_file_properties($file) { |
226 | 226 | $file->deleteUrl = $this->options['script_url'] |
227 | 227 | .$this->get_query_separator($this->options['script_url']) |
228 | | - .'file='.rawurlencode($file->name); |
| 228 | + .$this->get_singular_param_name() |
| 229 | + .'='.rawurlencode($file->name); |
229 | 230 | $file->deleteType = $this->options['delete_type']; |
230 | 231 | if ($file->deleteType !== 'DELETE') { |
231 | 232 | $file->deleteUrl .= '&_method=DELETE'; |
@@ -786,8 +787,22 @@ protected function get_version_param() { |
786 | 787 | return isset($_GET['version']) ? basename(stripslashes($_GET['version'])) : null; |
787 | 788 | } |
788 | 789 |
|
| 790 | + protected function get_singular_param_name() { |
| 791 | + return substr($this->options['param_name'], 0, -1); |
| 792 | + } |
| 793 | + |
789 | 794 | protected function get_file_name_param() { |
790 | | - return isset($_GET['file']) ? basename(stripslashes($_GET['file'])) : null; |
| 795 | + $name = $this->get_singular_param_name(); |
| 796 | + return isset($_GET[$name]) ? basename(stripslashes($_GET[$name])) : null; |
| 797 | + } |
| 798 | + |
| 799 | + protected function get_file_names_params() { |
| 800 | + $params = isset($_GET[$this->options['param_name']]) ? |
| 801 | + $_GET[$this->options['param_name']] : array(); |
| 802 | + foreach ($params as $key => $value) { |
| 803 | + $params[$key] = basename(stripslashes($value)); |
| 804 | + } |
| 805 | + return $params; |
791 | 806 | } |
792 | 807 |
|
793 | 808 | protected function get_file_type($file_path) { |
@@ -884,7 +899,7 @@ public function get($print_response = true) { |
884 | 899 | $file_name = $this->get_file_name_param(); |
885 | 900 | if ($file_name) { |
886 | 901 | $response = array( |
887 | | - substr($this->options['param_name'], 0, -1) => $this->get_file_object($file_name) |
| 902 | + $this->get_singular_param_name() => $this->get_file_object($file_name) |
888 | 903 | ); |
889 | 904 | } else { |
890 | 905 | $response = array( |
@@ -950,20 +965,27 @@ public function post($print_response = true) { |
950 | 965 | } |
951 | 966 |
|
952 | 967 | public function delete($print_response = true) { |
953 | | - $file_name = $this->get_file_name_param(); |
954 | | - $file_path = $this->get_upload_path($file_name); |
955 | | - $success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path); |
956 | | - if ($success) { |
957 | | - foreach($this->options['image_versions'] as $version => $options) { |
958 | | - if (!empty($version)) { |
959 | | - $file = $this->get_upload_path($file_name, $version); |
960 | | - if (is_file($file)) { |
961 | | - unlink($file); |
| 968 | + $file_names = $this->get_file_names_params(); |
| 969 | + if (empty($file_names)) { |
| 970 | + $file_names = array($this->get_file_name_param()); |
| 971 | + } |
| 972 | + $response = array(); |
| 973 | + foreach($file_names as $file_name) { |
| 974 | + $file_path = $this->get_upload_path($file_name); |
| 975 | + $success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path); |
| 976 | + if ($success) { |
| 977 | + foreach($this->options['image_versions'] as $version => $options) { |
| 978 | + if (!empty($version)) { |
| 979 | + $file = $this->get_upload_path($file_name, $version); |
| 980 | + if (is_file($file)) { |
| 981 | + unlink($file); |
| 982 | + } |
962 | 983 | } |
963 | 984 | } |
964 | 985 | } |
| 986 | + $response[$file_name] = $success; |
965 | 987 | } |
966 | | - return $this->generate_response(array('success' => $success), $print_response); |
| 988 | + return $this->generate_response($response, $print_response); |
967 | 989 | } |
968 | 990 |
|
969 | 991 | } |
0 commit comments