-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from ipuppet/dev
Dev
- Loading branch information
Showing
55 changed files
with
532 additions
and
1,615 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
|
||
namespace Ipuppet\Jade\Component\Http; | ||
|
||
|
||
use Ipuppet\Jade\Component\Parameter\Parameter; | ||
use Ipuppet\Jade\Component\Parameter\ParameterInterface; | ||
|
||
class Files extends Parameter implements ParameterInterface | ||
{ | ||
/** | ||
* 文件列表 | ||
* 每个值都是 包含该 form 字段上传的所有文件 的数组 | ||
* @var array | ||
*/ | ||
protected array $parameters; | ||
|
||
/** | ||
* @param array $files $_FILE | ||
*/ | ||
public function __construct(array $files) | ||
{ | ||
foreach ($files as $key => $file) { | ||
$this->parameters[$key] = []; | ||
if (is_array($file['name'])) { // 单个 form 字段包含多个文件 | ||
$len = count($file['name']); | ||
for ($i = 0; $i < $len; $i++) { | ||
$fileInstance = new File(); | ||
$this->parameters[$key][] = $fileInstance->setName($file['name'][$i]) | ||
->setSize($file['size'][$i]) | ||
->setTmpName($file['tmp_name'][$i]) | ||
->setType($file['type'][$i]) | ||
->setError($file['error'][$i]); | ||
} | ||
} else { // 单个 form 字段只有一个文件 | ||
$fileInstance = new File(); | ||
$this->parameters[$key][] = $fileInstance->setName($file['name']) | ||
->setSize($file['size']) | ||
->setTmpName($file['tmp_name']) | ||
->setType($file['type']) | ||
->setError($file['error']); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.