UploadFile.php
947 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace Lib;
/**
* 文件
* @author:dc
* @time 2023/3/13 14:34
* Class UploadFile
* @package Lib
*/
class UploadFile
{
/**
* @var string
*/
public string $name;
/**
* @var string
*/
public string $tempFile;
/**
* @var int
*/
public int $size;
/**
* @var string
*/
public string $mime;
/**
* @var string
*/
public string $ext;
/**
* UploadFile constructor.
* @param $name
* @param $tempFile
*/
public function __construct(string $name, string $tempFile)
{
parent::__construct($tempFile);
$this->name = $name;
$this->tempFile = $tempFile;
// kb
$this->size = (int) (filesize($this->tempFile)/1024);
// 文件类型
$this->mime = mime_content_type($this->tempFile);
$ext = explode('.',$name);
$this->ext = end($ext);
}
}