Skip to content

Commit a87bea6

Browse files
committed
- (Bug Fix) Fixed issue with uploading an array of files with the HttpRequestService
1 parent 1cb2640 commit a87bea6

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

models/Postmaster_HttpRequestServiceSettingsModel.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ public function parse(Array $data = array())
4343
return $this;
4444
}
4545

46+
public function addPostVar($name, $value)
47+
{
48+
$vars = $this->postVars;
49+
$vars[] = array('name' => $name, 'value' => $value);
50+
$this->postVars = $vars;
51+
}
52+
4653
public function getHeaders()
4754
{
4855
$headers = array();
@@ -61,7 +68,7 @@ public function getRequestVars()
6168

6269
foreach($this->postVars as $var)
6370
{
64-
$vars[$var['name']] = trim($var['value']);
71+
$vars[$var['name']] = is_string($var['value']) ? trim($var['value']) : $var['value'];
6572
}
6673

6774
foreach($this->files as $var)
@@ -70,8 +77,19 @@ public function getRequestVars()
7077

7178
if(!empty($value))
7279
{
73-
// $vars[$var['name']] = fopen($value, 'r');
74-
$vars[$var['name']] = '@' . $value;
80+
$values = explode("\n", $value);
81+
82+
if(count($values) > 1)
83+
{
84+
foreach($values as $index => $val)
85+
{
86+
$vars[preg_replace('/\[\]$/', '', $var['name']).'['.$index.']'] = '@' . $val;
87+
}
88+
}
89+
else if(count($values) == 1)
90+
{
91+
$vars[$var['name']] = '@' . $values[0];
92+
}
7593
}
7694
}
7795

0 commit comments

Comments
 (0)