Documentation

Verify
in package

Verification of file uploaded (Type|MIME) and extensions

Table of Contents

Properties

$DocumentsFile  : array<string|int, mixed>
$ImagesFile  : array<string|int, mixed>
$MimeTypes  : array<string|int, mixed>
List of signature file accepted
$VideosFile  : array<string|int, mixed>

Methods

getTypeFileAviable()  : array<string|int, mixed>
Return an extension list about the type given in parameter
verify()  : int|string
Verify the type of the value sent
verifyExtensionImage()  : int
Verify the picture extension sent
verifySignatureFile()  : bool
Verify the signature (MIME type) AND the extension of the file uploaded Principe : STRIC WHITE LIST only

Properties

$DocumentsFile

private static array<string|int, mixed> $DocumentsFile = ["pdf", "doc", "docx", "txt", "odt", "ppt", "pptx"]

$ImagesFile

private static array<string|int, mixed> $ImagesFile = ["png", "jpeg", "jpg", "gif"]

$MimeTypes

List of signature file accepted

private static array<string|int, mixed> $MimeTypes = [ // Documents "pdf" => ["application/pdf"], "doc" => ["application/msword"], "docx" => ["application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/zip"], "txt" => ["text/plain"], "odt" => ["application/vnd.oasis.opendocument.text", "application/zip"], "ppt" => ["application/vnd.ms-powerpoint"], "pptx" => ["application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/zip"], // Pictures "png" => ["image/png"], "jpeg" => ["image/jpeg"], "jpg" => ["image/jpeg"], "gif" => ["image/gif"], // Videos "mov" => ["video/quicktime"], "mp4" => ["video/mp4"], "m4a" => ["audio/mp4", "audio/x-m4a"], ]

Mime Types authorized for each "type" of file

$VideosFile

private static array<string|int, mixed> $VideosFile = ["mov", "mp4", "m4a"]

Methods

getTypeFileAviable()

Return an extension list about the type given in parameter

public static getTypeFileAviable(string $AType) : array<string|int, mixed>
Parameters
$AType : string

File's type expected (Documents, Pictures, Videos)

Return values
array<string|int, mixed>

Return the extension list

verify()

Verify the type of the value sent

public static verify(string $input, string $typeToHave) : int|string
Parameters
$input : string

The value to verify

$typeToHave : string

The type to expect

Return values
int|string

return 1 if the type verified is correct le type vérifié, else false, if the type requested is unknow, the return null

verifyExtensionImage()

Verify the picture extension sent

public static verifyExtensionImage(string $File) : int
Parameters
$File : string

File's path to verify

Return values
int

return 1 if the file extension is in the list of expected format, else return 0

verifySignatureFile()

Verify the signature (MIME type) AND the extension of the file uploaded Principe : STRIC WHITE LIST only

public static verifySignatureFile(string $FileTmpName, string $FileName, string $FileType) : bool
Parameters
$FileTmpName : string

Temp file's path

$FileName : string

Original name of the file

$FileType : string

File type expected (Documents, Pictures, Videos)

Return values
bool

if everything is like expected, return true, else, return false


        
On this page

Search results