phpBB API Documentation
Class

phpbb\files\filespec_storage

class filespec_storage

Responsible for holding all file relevant information, as well as doing file-specific operations.

The {@link fileupload fileupload class} can be used to upload several files, each of them being this object to operate further on.

Properties

array $error
upload $upload

Methods

__construct(language $language, IniGetWrapper $php_ini, FastImageSize $imagesize, guesser $mimetype_guesser = null, plupload $plupload = null)

File upload class

filespec set_upload_ary(array $upload_ary)

Set upload ary

filespec set_upload_namespace(upload $namespace)

Set the upload namespace

bool init_error()

Check if class members were not properly initialised yet

filespec set_error(mixed $error)

Set error in error array

clean_filename(string $mode = 'unique', string $prefix = '', string $user_id = '')

Cleans destination filename

mixed get(string $property)

Get property from file object

bool is_image()

Check if file is an image (mime type)

bool is_uploaded()

Check if the file got correctly uploaded

remove($storage)

Remove file

static string get_extension(string $filename)

Get file extension

string get_mimetype(string $filename)

Get mime type

int get_filesize(string $filename)

Get file size

bool check_content(array $disallowed_content)

Check the first 256 bytes for forbidden content

bool move_file($storage, $overwrite = false, $skip_image_check = false)

Move file to destination folder

bool additional_checks()

Performing additional checks

Details

at line 93
public __construct(language $language, IniGetWrapper $php_ini, FastImageSize $imagesize, guesser $mimetype_guesser = null, plupload $plupload = null)

File upload class

Parameters

language $language Language
IniGetWrapper $php_ini ini_get() wrapper
FastImageSize $imagesize Imagesize class
guesser $mimetype_guesser Mime type guesser
plupload $plupload Plupload

at line 109
public filespec set_upload_ary(array $upload_ary)

Set upload ary

Parameters

array $upload_ary Upload ary

Return Value

filespec This instance of the filespec class

at line 152
public filespec set_upload_namespace(upload $namespace)

Set the upload namespace

Parameters

upload $namespace Instance of upload class

Return Value

filespec This instance of the filespec class

at line 164
public bool init_error()

Check if class members were not properly initialised yet

Return Value

bool True if there was an init error, false if not

at line 176
public filespec set_error(mixed $error)

Set error in error array

Parameters

mixed $error Content for error array

Return Value

filespec This instance of the filespec class

at line 192
public clean_filename(string $mode = 'unique', string $prefix = '', string $user_id = '')

Cleans destination filename

Parameters

string $mode Either real, unique, or unique_ext. Real creates a realname, filtering some characters, lowering every character. Unique creates a unique filename.
string $prefix Prefix applied to filename
string $user_id The user_id is only needed for when cleaning a user's avatar

at line 240
public mixed get(string $property)

Get property from file object

Parameters

string $property Name of property

Return Value

mixed Content of property

at line 255
public bool is_image()

Check if file is an image (mime type)

Return Value

bool true if it is an image, false if not

at line 265
public bool is_uploaded()

Check if the file got correctly uploaded

Return Value

bool true if it is a valid upload, false if not

at line 285
public remove($storage)

Remove file

Parameters

$storage

at line 304
static public string get_extension(string $filename)

Get file extension

Parameters

string $filename Filename that needs to be checked

Return Value

string Extension of the supplied filename

at line 323
public string get_mimetype(string $filename)

Get mime type

Parameters

string $filename Filename that needs to be checked

Return Value

string Mime type of supplied filename

at line 345
public int get_filesize(string $filename)

Get file size

Parameters

string $filename File name of file to check

Return Value

int File size

at line 358
public bool check_content(array $disallowed_content)

Check the first 256 bytes for forbidden content

Parameters

array $disallowed_content Array containg disallowed content

Return Value

bool False if disallowed content found, true if not

at line 391
public bool move_file($storage, $overwrite = false, $skip_image_check = false)

Move file to destination folder

Parameters

$storage
$overwrite
$skip_image_check

Return Value

bool True if file was moved, false if not

at line 486
public bool additional_checks()

Performing additional checks

Return Value

bool False if issue was found, true if not