1: <?php
2:
3: namespace PHPixie\HTTP\Messages\UploadedFile;
4:
5: use PHPixie\HTTP\Messages;
6: use RuntimeException;
7:
8: 9: 10:
11: class SAPI extends \PHPixie\HTTP\Messages\UploadedFile
12: {
13: 14: 15: 16: 17:
18: public function __construct($messages, $fileData)
19: {
20: parent::__construct($messages);
21:
22: $this->clientFilename = $fileData['name'];
23: $this->clientMediaType = $fileData['type'];
24: $this->file = $fileData['tmp_name'];
25: $this->error = $fileData['error'];
26: $this->size = $fileData['size'];
27: }
28:
29: 30: 31:
32: public function moveTo($path)
33: {
34: $this->assertValidUpload();
35: if(!$this->moveUploadedFile($path)) {
36: throw new RuntimeException("Failed to move uploaded file '{$this->file}' to '$path'");
37: }
38: }
39:
40: 41: 42: 43:
44: protected function moveUploadedFile($path)
45: {
46: return move_uploaded_file($this->file, $path);
47: }
48: }