1 | <?php |
||
10 | class FileInfo |
||
11 | { |
||
12 | /** |
||
13 | * has error |
||
14 | * @var boolean |
||
15 | */ |
||
16 | public $hasError; |
||
17 | |||
18 | /** |
||
19 | * tmp filename, $_FILES['upfile']['tmp_name'] |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $tmpName; |
||
23 | |||
24 | /** |
||
25 | * Original file name(the name saved on the client); $_FILES['upfile']['name'] |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $originName; |
||
29 | |||
30 | /** |
||
31 | * errors;$_FILES['error'] |
||
32 | * @var int |
||
33 | */ |
||
34 | protected $error; |
||
35 | |||
36 | /** |
||
37 | * file size(bytes);$_FILES['upfile']['size'] |
||
38 | * @var int |
||
39 | */ |
||
40 | protected $size; |
||
41 | |||
42 | /** |
||
43 | * file type;$_FILES['upfile']['type'] |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $type; |
||
47 | |||
48 | /** |
||
49 | * file mime type |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $mimeType; |
||
53 | |||
54 | /** |
||
55 | * error code |
||
56 | * @var int |
||
57 | */ |
||
58 | protected $errorCode; |
||
59 | |||
60 | /** |
||
61 | * error message |
||
62 | * @var string |
||
63 | */ |
||
64 | protected $errorMsg; |
||
65 | |||
66 | /** |
||
67 | * The file path after upload |
||
68 | * @var string |
||
69 | */ |
||
70 | protected $path; |
||
71 | |||
72 | public function __construct(array $file) |
||
88 | |||
89 | /** |
||
90 | * Create instance from array |
||
91 | * @param array $info |
||
92 | * @return FileInfo |
||
93 | */ |
||
94 | public static function fromArray(array $info) |
||
98 | |||
99 | /** |
||
100 | * Create instance from array |
||
101 | * @param array $info |
||
102 | * @return FileInfo |
||
103 | * @deprecated |
||
104 | */ |
||
105 | public static function createFromArray(array $info) |
||
109 | |||
110 | /** |
||
111 | * gets file size |
||
112 | * @return int |
||
113 | */ |
||
114 | public function getSize() |
||
118 | |||
119 | /** |
||
120 | * gets file mime type |
||
121 | * @return string |
||
122 | */ |
||
123 | public function getMimeType() |
||
130 | |||
131 | /** |
||
132 | * detect file mime type |
||
133 | * @return string |
||
134 | */ |
||
135 | protected function detectMimeType() |
||
148 | |||
149 | /** |
||
150 | * gets file extension |
||
151 | * @return string |
||
152 | */ |
||
153 | public function getExtension() |
||
157 | |||
158 | /** |
||
159 | * gets file tmp name |
||
160 | * @return string |
||
161 | */ |
||
162 | public function getTmpName() |
||
166 | |||
167 | /** |
||
168 | * gets original file name |
||
169 | * @return string |
||
170 | */ |
||
171 | public function getOriginName() |
||
175 | |||
176 | /** |
||
177 | * gets file type |
||
178 | * @return string |
||
179 | */ |
||
180 | public function getType() |
||
184 | |||
185 | /** |
||
186 | * gets error($_FILES['upfile']['error']) |
||
187 | * @return int |
||
188 | */ |
||
189 | public function getError() |
||
193 | |||
194 | /** |
||
195 | * set error code |
||
196 | * @param int $code |
||
197 | */ |
||
198 | public function setErrorCode($code) |
||
202 | |||
203 | /** |
||
204 | * gets final error code |
||
205 | * @return int |
||
206 | */ |
||
207 | public function getErrorCode() |
||
211 | |||
212 | /** |
||
213 | * set error message |
||
214 | * @param string $msg |
||
215 | */ |
||
216 | public function setErrorMsg($msg) |
||
220 | |||
221 | /** |
||
222 | * get error message |
||
223 | * @return string |
||
224 | */ |
||
225 | public function getErrorMsg() |
||
229 | |||
230 | /** |
||
231 | * set file path |
||
232 | * @param string $path |
||
233 | */ |
||
234 | public function setPath($path) |
||
238 | |||
239 | /** |
||
240 | * get file path |
||
241 | * @return string |
||
242 | */ |
||
243 | public function getPath() |
||
247 | |||
248 | /** |
||
249 | * whether there is an error |
||
250 | * @return bool |
||
251 | */ |
||
252 | public function hasError() |
||
256 | |||
257 | /** |
||
258 | * set has error |
||
259 | * @param $result |
||
260 | */ |
||
261 | public function setHasError($result) |
||
265 | |||
266 | /** |
||
267 | * Convert human readable file size (e.g. "10K" or "3M") into bytes |
||
268 | * @link https://github.com/brandonsavage/Upload/blob/master/src/Upload/File.php#L446 |
||
269 | * @param string $input |
||
270 | * @return int |
||
271 | */ |
||
272 | public static function humanReadableToBytes($input) |
||
287 | } |
||
288 |
This method has been deprecated.