FileUploader

FileUploader

File Upload Class

Methods

__construct

FileUploader::__construct( \Gibbon\Contracts\Database\Connection $pdo, \Gibbon\session $session )

getIllegalFileExtensions

Get the list of hard-coded illegal extensions.

static FileUploader::getIllegalFileExtensions( ): array

Return Value: array


upload

Upload a file from a submitted form, checking file extensions and generating a randomized name.

FileUploader::upload( string $filename, string $sourcePath, string $destinationFolder = '' ): string|boolean

Return Value: string|boolean Resulting path of the uploaded file, FALSE on failure.


uploadFromPost

Convenience function for handling file uploads from $_FILES array. Also handles file upload errors from POST.

FileUploader::uploadFromPost( array $file, $filenameChange = '' ): string|boolean

Return Value: string|boolean


getUploadsFolderByDate

Get an absolute uploads folder path based on UNIX timestamp.

FileUploader::getUploadsFolderByDate( string $timestamp ): string|boolean

Return Value: string|boolean Returns the path, FALSE on failure.


getRandomizedFilename

Randomize the provided filename by adding an alphanumeric string and ensuring uniqueness.

FileUploader::getRandomizedFilename( string $filename, $destinationFolder ): string|boolean

Return Value: string|boolean Returns the filename, FALSE on failure.


getFileExtensions

Lazy load an array of the File Extensions from DB. Optionally loads specific types of extensions (accepts array or CSV list).

FileUploader::getFileExtensions( $type = '' ): array

Return Value: array


getFileExtensionsCSV

Get the valid extensions as CSV; helper method for validation fields.

FileUploader::getFileExtensionsCSV( ): array

Return Value: array


setFileExtensions

Set the file extensions from an array. Overrides the list normally retrieved from the database.

FileUploader::setFileExtensions( array $extensions )

isFileTypeValid

Checks the extension of the filename provided against the list of valid extensions. Handle extensions without full filename.

FileUploader::isFileTypeValid( string $filename ): boolean

Return Value: boolean


setFileSuffixType

FileUploader::setFileSuffixType( $value )

getLastError

Return the last error generated by the uploader.

FileUploader::getLastError( ): integer

Return Value: integer


Last updated : September 15, 2018 b92362d