1
1
<?php
2
2
/*
3
- * jQuery File Upload Plugin PHP Example 4.2
3
+ * jQuery File Upload Plugin PHP Example 4.2.1
4
4
* https://github.com/blueimp/jQuery-File-Upload
5
5
*
6
6
* Copyright 2010, Sebastian Tschan
27
27
class UploadHandler
28
28
{
29
29
private $ upload_dir ;
30
+ private $ upload_url ;
30
31
private $ thumbnails_dir ;
32
+ private $ thumbnails_url ;
31
33
private $ thumbnail_max_width ;
32
34
private $ thumbnail_max_height ;
33
35
private $ field_name ;
@@ -147,7 +149,8 @@ private function handle_file_upload($uploaded_file, $name, $size, $type) {
147
149
}
148
150
149
151
public function get () {
150
- $ file_name = isset ($ _REQUEST ['file ' ]) ? basename (stripslashes ($ _REQUEST ['file ' ])) : null ;
152
+ $ file_name = isset ($ _REQUEST ['file ' ]) ?
153
+ basename (stripslashes ($ _REQUEST ['file ' ])) : null ;
151
154
if ($ file_name ) {
152
155
$ info = $ this ->get_file_object ($ file_name );
153
156
} else {
@@ -180,12 +183,12 @@ public function post() {
180
183
} else {
181
184
$ info = $ this ->handle_file_upload (
182
185
$ upload ['tmp_name ' ],
183
- isset ($ _SERVER ['HTTP_X_FILE_NAME ' ]) ? $ _SERVER [ ' HTTP_X_FILE_NAME ' ] :
184
- $ upload ['name ' ],
185
- isset ($ _SERVER ['HTTP_X_FILE_SIZE ' ]) ? $ _SERVER [ ' HTTP_X_FILE_SIZE ' ] :
186
- $ upload ['size ' ],
187
- isset ($ _SERVER ['HTTP_X_FILE_TYPE ' ]) ? $ _SERVER [ ' HTTP_X_FILE_TYPE ' ] :
188
- $ upload ['type ' ]
186
+ isset ($ _SERVER ['HTTP_X_FILE_NAME ' ]) ?
187
+ $ _SERVER [ ' HTTP_X_FILE_NAME ' ] : $ upload ['name ' ],
188
+ isset ($ _SERVER ['HTTP_X_FILE_SIZE ' ]) ?
189
+ $ _SERVER [ ' HTTP_X_FILE_SIZE ' ] : $ upload ['size ' ],
190
+ isset ($ _SERVER ['HTTP_X_FILE_TYPE ' ]) ?
191
+ $ _SERVER [ ' HTTP_X_FILE_TYPE ' ] : $ upload ['type ' ]
189
192
);
190
193
}
191
194
} else {
@@ -201,7 +204,8 @@ public function post() {
201
204
}
202
205
203
206
public function delete () {
204
- $ file_name = isset ($ _REQUEST ['file ' ]) ? basename (stripslashes ($ _REQUEST ['file ' ])) : null ;
207
+ $ file_name = isset ($ _REQUEST ['file ' ]) ?
208
+ basename (stripslashes ($ _REQUEST ['file ' ])) : null ;
205
209
$ file_path = $ this ->upload_dir .$ file_name ;
206
210
$ thumbnail_path = $ this ->thumbnails_dir .$ file_name ;
207
211
$ success = is_file ($ file_path ) && $ file_name [0 ] !== '. ' && unlink ($ file_path );
0 commit comments