phpBB API Documentation
Class

phpbb\files\filespec

class filespec

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(filesystem_interface $phpbb_filesystem, language $language, IniGetWrapper $php_ini, FastImageSize $imagesize, string $phpbb_root_path, 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()

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(string $destination, bool $overwrite = false, bool $skip_image_check = false, string|bool $chmod = false)

Move file to destination folder The phpbbrootpath variable will be applied to the destination path

bool additional_checks()

Performing additional checks

Details

at line 104
public __construct(filesystem_interface $phpbb_filesystem, language $language, IniGetWrapper $php_ini, FastImageSize $imagesize, string $phpbb_root_path, guesser $mimetype_guesser = null, plupload $plupload = null)

File upload class

Parameters

filesystem_interface $phpbb_filesystem Filesystem
language $language Language
IniGetWrapper $php_ini ini_get() wrapper
FastImageSize $imagesize Imagesize class
string $phpbb_root_path phpBB root path
guesser $mimetype_guesser Mime type guesser
plupload $plupload Plupload

at line 122
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 165
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 177
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 189
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 205
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 253
public mixed get(string $property)

Get property from file object

Parameters

string $property Name of property

Return Value

mixed Content of property

at line 268
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 278
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 298
public remove()

Remove file

at line 313
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 332
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 354
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 367
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 404
public bool move_file(string $destination, bool $overwrite = false, bool $skip_image_check = false, string|bool $chmod = false)

Move file to destination folder The phpbbrootpath variable will be applied to the destination path

Parameters

string $destination Destination path, for example $config['avatar_path']
bool $overwrite If set to true, an already existing file will be overwritten
bool $skip_image_check If set to true, the check for the file to be a valid image is skipped
string|bool $chmod Permission mask for chmodding the file after a successful move. The mode entered here reflects the mode defined by {@link phpbb_chmod()}

Return Value

bool True if file was moved, false if not

at line 552
public bool additional_checks()

Performing additional checks

Return Value

bool False if issue was found, true if not