1 | <?php |
||
30 | class Uploaded extends File |
||
31 | { |
||
32 | /** |
||
33 | * Whether the test mode is activated. |
||
34 | * Local files are used in test mode hence the code should not enforce HTTP uploads. |
||
35 | * |
||
36 | * @var bool |
||
37 | */ |
||
38 | private $test = false; |
||
39 | |||
40 | /** |
||
41 | * The original name of the uploaded file. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | private $name; |
||
46 | |||
47 | /** |
||
48 | * The mime type provided by the uploader. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | private $mime; |
||
53 | |||
54 | /** |
||
55 | * The file size provided by the uploader. |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | private $size; |
||
60 | |||
61 | /** |
||
62 | * The UPLOAD_ERR_XXX constant provided by the uploader. |
||
63 | * |
||
64 | * @var integer |
||
65 | */ |
||
66 | private $error; |
||
67 | |||
68 | /** |
||
69 | * Accepts the information of the uploaded file as provided by the PHP global $_FILES. |
||
70 | * |
||
71 | * <code> |
||
72 | * // Create a file instance. |
||
73 | * $file = new Uploaded( |
||
74 | * $_FILES['tmp_name'], $_FILES['name'], $_FILES['type'], $_FILES['size'], $_FILES['error'] |
||
75 | * ); |
||
76 | * </code> |
||
77 | * |
||
78 | * @param string $path The full temporary path to the file |
||
79 | * @param string $name The original file name |
||
80 | * @param string|null $mime The type of the file as provided by PHP |
||
81 | * @param string|null $size The file size |
||
82 | * @param int|null $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants) |
||
83 | * @param bool $test Whether the test mode is active |
||
84 | * |
||
85 | * @throws \RuntimeException If file_uploads is disabled |
||
86 | */ |
||
87 | public function __construct($path, $name, $mime = null, $size = null, $error = null, $test = false) |
||
101 | |||
102 | /** |
||
103 | * Returns the original file name. |
||
104 | * |
||
105 | * It is extracted from the request from which the file has been uploaded. |
||
106 | * Then is should not be considered as a safe value. |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | public function getClientOriginalName() |
||
114 | |||
115 | /** |
||
116 | * Returns the file mime type. |
||
117 | * |
||
118 | * It is extracted from the request from which the file has been uploaded. |
||
119 | * Then is should not be considered as a safe value. |
||
120 | * |
||
121 | * @return string |
||
122 | */ |
||
123 | public function getClientMimeType() |
||
127 | |||
128 | /** |
||
129 | * Returns the file size. |
||
130 | * |
||
131 | * It is extracted from the request from which the file has been uploaded. |
||
132 | * Then is should not be considered as a safe value. |
||
133 | * |
||
134 | * @return string|null |
||
135 | */ |
||
136 | public function getClientSize() |
||
140 | |||
141 | /** |
||
142 | * Returns the upload error. |
||
143 | * |
||
144 | * If the upload was successful, the constant UPLOAD_ERR_OK is returned. |
||
145 | * Otherwise one of the other UPLOAD_ERR_XXX constants is returned. |
||
146 | * |
||
147 | * @return integer |
||
148 | */ |
||
149 | public function getError() |
||
153 | |||
154 | /** |
||
155 | * Returns whether the file was uploaded successfully. |
||
156 | * |
||
157 | * @return boolean True if no error occurred during uploading |
||
158 | */ |
||
159 | public function isValid() |
||
163 | |||
164 | /** |
||
165 | * Moves the file to a new location. |
||
166 | * |
||
167 | * @param string $dir |
||
168 | * @param null $name |
||
169 | * |
||
170 | * @return \Pimf\Util\File |
||
171 | * @throws \RuntimeException If the file has not been uploaded via Http or can not move the file. |
||
172 | */ |
||
173 | public function move($dir, $name = null) |
||
195 | |||
196 | /** |
||
197 | * Returns the maximum size of an uploaded file in bytes as configured in php.ini |
||
198 | * |
||
199 | * @return int |
||
200 | */ |
||
201 | public static function getMaxFilesize() |
||
218 | } |
||
219 |