1 | <?php |
||
12 | class UploadedFileHelper |
||
13 | { |
||
14 | /** |
||
15 | * Check if uploaded File is valid and |
||
16 | * has a valid Mime Type (only if $arrMimeType is not empty array). |
||
17 | * Return true is all ok, otherwise return false. |
||
18 | * @param UploadedFile $uploadedFile |
||
19 | * @param array $arrMimeType |
||
20 | * @return bool |
||
21 | */ |
||
22 | public static function isValidUploadFile(UploadedFile $uploadedFile, array $arrMimeType = array()) : bool |
||
30 | |||
31 | /** |
||
32 | * Check if uploaded File has a correct MimeType if specified. |
||
33 | * If $arrMimeType is empty array return true. |
||
34 | * @param UploadedFile $uploadedFile |
||
35 | * @param array $arrMimeType |
||
36 | * @return bool |
||
37 | */ |
||
38 | public static function hasValidMimeType(UploadedFile $uploadedFile, array $arrMimeType) : bool |
||
42 | |||
43 | /** |
||
44 | * Return the file name of uploaded file (without path and witout extension). |
||
45 | * Ex.: /public/upload/pippo.txt ritorna 'pippo' |
||
46 | * @param UploadedFile $uploadedFile |
||
47 | * @return string |
||
48 | */ |
||
49 | public static function getFilenameWithoutExtension(UploadedFile $uploadedFile) |
||
53 | |||
54 | /** |
||
55 | * Return the file name with extension of uploaded file (without path). |
||
56 | * Ex.: /public/upload/pippo.txt ritorna 'pippo.txt' |
||
57 | * @param UploadedFile $uploadedFile |
||
58 | * @return string |
||
59 | */ |
||
60 | public static function getFilenameWithExtension(UploadedFile $uploadedFile) |
||
64 | |||
65 | /** |
||
66 | * Return the only file extension (without dot). |
||
67 | * Ex.: /public/upload/pippo.txt ritorna 'txt' |
||
68 | * @param UploadedFile $uploadedFile |
||
69 | * @return string |
||
70 | */ |
||
71 | public static function getFilenameExtension(UploadedFile $uploadedFile) |
||
75 | |||
76 | /** |
||
77 | * Return the dir name of uploaded file (without file name and witout extension). |
||
78 | * Ex.: /public/upload/pippo.txt ritorna '/public/upload' |
||
79 | * @param UploadedFile $uploadedFile |
||
80 | * @return string |
||
81 | */ |
||
82 | public static function getDirname(UploadedFile $uploadedFile) |
||
86 | |||
87 | } |
||
88 |