Skip to content

Commit af27fd8

Browse files
committed
Fixed parsing of $_FILES as one-dimensional array.
Thanks to Julien Künzi for the report.
1 parent 33650a9 commit af27fd8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

server/php/upload.class.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* jQuery File Upload Plugin PHP Class 5.9
3+
* jQuery File Upload Plugin PHP Class 5.9.1
44
* https://github.com/blueimp/jQuery-File-Upload
55
*
66
* Copyright 2010, Sebastian Tschan
@@ -333,6 +333,8 @@ public function post() {
333333
$_FILES[$this->options['param_name']] : null;
334334
$info = array();
335335
if ($upload && is_array($upload['tmp_name'])) {
336+
// param_name is an array identifier like "files[]",
337+
// $_FILES is a multi-dimensional array:
336338
foreach ($upload['tmp_name'] as $index => $value) {
337339
$info[] = $this->handle_file_upload(
338340
$upload['tmp_name'][$index],
@@ -346,17 +348,19 @@ public function post() {
346348
);
347349
}
348350
} elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) {
351+
// param_name is a single object identifier like "file",
352+
// $_FILES is a one-dimensional array:
349353
$info[] = $this->handle_file_upload(
350354
isset($upload['tmp_name']) ? $upload['tmp_name'] : null,
351355
isset($_SERVER['HTTP_X_FILE_NAME']) ?
352356
$_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name']) ?
353-
isset($upload['name']) : null),
357+
$upload['name'] : null),
354358
isset($_SERVER['HTTP_X_FILE_SIZE']) ?
355359
$_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size']) ?
356-
isset($upload['size']) : null),
360+
$upload['size'] : null),
357361
isset($_SERVER['HTTP_X_FILE_TYPE']) ?
358362
$_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type']) ?
359-
isset($upload['type']) : null),
363+
$upload['type'] : null),
360364
isset($upload['error']) ? $upload['error'] : null
361365
);
362366
}

0 commit comments

Comments
 (0)