Skip to content

Commit 6d61a78

Browse files
committed
Content-range header fix for response content wrapped as object. Fixes blueimp#1942.
1 parent fb455d8 commit 6d61a78

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

server/php/UploadHandler.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* jQuery File Upload Plugin PHP Class 6.0
3+
* jQuery File Upload Plugin PHP Class 6.0.1
44
* https://github.com/blueimp/jQuery-File-Upload
55
*
66
* Copyright 2010, Sebastian Tschan
@@ -561,9 +561,10 @@ protected function generate_response($content, $print_response = true) {
561561
return;
562562
}
563563
$this->head();
564-
if (isset($_SERVER['HTTP_CONTENT_RANGE']) && is_array($content) &&
565-
is_object($content[0]) && $content[0]->size) {
566-
$this->header('Range: 0-'.($this->fix_integer_overflow(intval($content[0]->size)) - 1));
564+
$files = $content[$this->options['param_name']];
565+
if (isset($_SERVER['HTTP_CONTENT_RANGE']) && is_array($files) &&
566+
is_object($files[0]) && $files[0]->size) {
567+
$this->header('Range: 0-'.($this->fix_integer_overflow(intval($files[0]->size)) - 1));
567568
}
568569
$this->body($json);
569570
}
@@ -657,9 +658,13 @@ public function get($print_response = true) {
657658
}
658659
$file_name = $this->get_file_name_param();
659660
if ($file_name) {
660-
$response = array('file' => $this->get_file_object($file_name));
661+
$response = array(
662+
substr($this->options['param_name'], 0, -1) => $this->get_file_object($file_name)
663+
);
661664
} else {
662-
$response = array('files' => $this->get_file_objects());
665+
$response = array(
666+
$this->options['param_name'] => $this->get_file_objects()
667+
);
663668
}
664669
return $this->generate_response($response, $print_response);
665670
}
@@ -713,7 +718,10 @@ public function post($print_response = true) {
713718
$content_range
714719
);
715720
}
716-
return $this->generate_response(array('files' => $files), $print_response);
721+
return $this->generate_response(
722+
array($this->options['param_name'] => $files),
723+
$print_response
724+
);
717725
}
718726

719727
public function delete($print_response = true) {

0 commit comments

Comments
 (0)