Skip to content

Commit

Permalink
Fixed parsing of $_FILES as one-dimensional array.
Browse files Browse the repository at this point in the history
Thanks to Julien Künzi for the report.
  • Loading branch information
blueimp committed Mar 8, 2012
1 parent 33650a9 commit af27fd8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions server/php/upload.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* jQuery File Upload Plugin PHP Class 5.9
* jQuery File Upload Plugin PHP Class 5.9.1
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
Expand Down Expand Up @@ -333,6 +333,8 @@ public function post() {
$_FILES[$this->options['param_name']] : null;
$info = array();
if ($upload && is_array($upload['tmp_name'])) {
// param_name is an array identifier like "files[]",
// $_FILES is a multi-dimensional array:
foreach ($upload['tmp_name'] as $index => $value) {
$info[] = $this->handle_file_upload(
$upload['tmp_name'][$index],
Expand All @@ -346,17 +348,19 @@ public function post() {
);
}
} elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) {
// param_name is a single object identifier like "file",
// $_FILES is a one-dimensional array:
$info[] = $this->handle_file_upload(
isset($upload['tmp_name']) ? $upload['tmp_name'] : null,
isset($_SERVER['HTTP_X_FILE_NAME']) ?
$_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name']) ?
isset($upload['name']) : null),
$upload['name'] : null),
isset($_SERVER['HTTP_X_FILE_SIZE']) ?
$_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size']) ?
isset($upload['size']) : null),
$upload['size'] : null),
isset($_SERVER['HTTP_X_FILE_TYPE']) ?
$_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type']) ?
isset($upload['type']) : null),
$upload['type'] : null),
isset($upload['error']) ? $upload['error'] : null
);
}
Expand Down

0 comments on commit af27fd8

Please sign in to comment.