z_upload
in package
Class that handles file uploads and checking types
Table of Contents
- $extension : string
- $fileId : int
- $filePath : string
- $mime : string
- $ref : string
- $size : int
- $srcName : string
- $res : Request
- __construct() : mixed
- Creates the upload object
- audio() : int
- Uploads a file, which must be an audio
- image() : int
- Uploads a file, which must be an image
- upload() : int
- Uploads a file to an upload folder
- video() : int
- Uploads a file, which must be a video
Properties
$extension
public
string
$extension
File extension of the uploading file
$fileId
public
int
$fileId
File Id, set after upload
$filePath
public
string
$filePath
Path to the uploading file
$mime
public
string
$mime
MIME-Type
$ref
public
string
$ref
Reference
$size
public
int
$size
Size of the uploading file in bytes
$srcName
public
string
$srcName
Source name of the uploading file
$res
private
Request
$res
Request object of the current request
Methods
__construct()
Creates the upload object
public
__construct(mixed $res) : mixed
Parameters
- $res : mixed
Return values
mixed —audio()
Uploads a file, which must be an audio
public
audio(string $file, string $uploadDir[, string $maxSize = FILE_SIZE_10MB ]) : int
An implementation of the upload method with a audio filter. This function will handle file uploads for you and make sure the type and the size are as defined. It also handles the movement to an upload folder. Be sure to change upload_max_filesize and post_max_size in you php.ini
Parameters
- $file : string
-
The file attribute from POST. Example $_POST["voice_rec"]
- $uploadDir : string
-
The path to which the file will be uploaded
- $maxSize : string = FILE_SIZE_10MB
-
The maximum size of the file. Use the defined constants like FILE_SIZE_10MB
Return values
int —The result of the upload. This could be something like UPLOAD_SUCCESS or UPLOAD_ERROR_TOO_BIG
image()
Uploads a file, which must be an image
public
image(string $file, string $uploadDir[, string $maxSize = FILE_SIZE_2MB ]) : int
An implementation of the upload method with an image filter. This function will handle file uploads for you and make sure the type and the size are as defined. It also handles the movement to an upload folder. Be sure to change upload_max_filesize and post_max_size in you php.ini
Parameters
- $file : string
-
The file attribute from POST. Example $_POST["profile_picture"]
- $uploadDir : string
-
The path to which the file will be uploaded
- $maxSize : string = FILE_SIZE_2MB
-
The maximum size of the file. Use the defined constants like FILE_SIZE_2MB
Return values
int —The result of the upload. This could be something like UPLOAD_SUCCESS or UPLOAD_ERROR_TOO_BIG
upload()
Uploads a file to an upload folder
public
upload(string $file, string $uploadDir, string $maxSize, array<string|int, string> $typeArray) : int
This function will handle file uploads for you and make sure the type and the size are as defined. It also handles the movement to an upload folder. Be sure to change upload_max_filesize and post_max_size in you php.ini
Parameters
- $file : string
-
The file attribute from POST. Example $_POST["profile_picture"]
- $uploadDir : string
-
The path to which the file will be uploaded
- $maxSize : string
-
The maximum size of the file. Use the defined constants like FILE_SIZE_2MB
- $typeArray : array<string|int, string>
-
An array of allowed filetypes like ["jpg", "png"]
Return values
int —The result of the upload. This could be something like UPLOAD_SUCCESS or UPLOAD_ERROR_TOO_BIG
video()
Uploads a file, which must be a video
public
video(string $file, string $uploadDir[, string $maxSize = FILE_SIZE_100MB ]) : int
An implementation of the upload method with a video filter. This function will handle file uploads for you and make sure the type and the size are as defined. It also handles the movement to an upload folder. Be sure to change upload_max_filesize and post_max_size in you php.ini
Parameters
- $file : string
-
The file attribute from POST. Example $_POST["recording"]
- $uploadDir : string
-
The path to which the file will be uploaded
- $maxSize : string = FILE_SIZE_100MB
-
The maximum size of the file. Use the defined constants like FILE_SIZE_100MB
Return values
int —The result of the upload. This could be something like UPLOAD_SUCCESS or UPLOAD_ERROR_TOO_BIG