phpBB API Documentation
Class

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

$filename
$realname
$uploadname
$mimetype
$extension
$filesize
$width
$height
$image_info
$destination_file
$destination_path
$file_moved
$init_error
$local
$error
$upload

Methods

filespec($upload_ary, $upload_namespace, guesser $mimetype_guesser = null, plupload $plupload = null)

File Class

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

Cleans destination filename

get($property)

Get property from file object

true is_image()

Check if file is an image (mimetype)

true 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 mimetype

get_filesize($filename)

Get filesize

check_content($disallowed_content)

Check the first 256 bytes for forbidden content

move_file(string $destination, bool $overwrite = false, bool $skip_image_check = false, string $chmod = false)

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

additional_checks()

Performing additional checks

Details

at line 65
public filespec($upload_ary, $upload_namespace, guesser $mimetype_guesser = null, plupload $plupload = null)

File Class

Parameters

$upload_ary
$upload_namespace
guesser $mimetype_guesser
plupload $plupload

at line 110
public clean_filename(real|unique|unique_ext $mode = 'unique', string $prefix = '', string $user_id = '')

Cleans destination filename

Parameters

real|unique|unique_ext $mode real creates a realname, filtering some characters, lowering every character. Unique creates an 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 155
public get($property)

Get property from file object

Parameters

$property

at line 170
public true is_image()

Check if file is an image (mimetype)

Return Value

true if it is an image, false if not

at line 180
public true is_uploaded()

Check if the file got correctly uploaded

Return Value

true if it is a valid upload, false if not

at line 200
public remove()

Remove file

at line 214
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 233
public string get_mimetype(string $filename)

Get mimetype

Parameters

string $filename Filename that needs to be checked

Return Value

string Mimetype of supplied filename

at line 251
public get_filesize($filename)

Get filesize

Parameters

$filename

at line 260
public check_content($disallowed_content)

Check the first 256 bytes for forbidden content

Parameters

$disallowed_content

at line 295
public move_file(string $destination, bool $overwrite = false, bool $skip_image_check = false, string $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 $chmod Permission mask for chmodding the file after a successful move. The mode entered here reflects the mode defined by {@link phpbb_chmod()}

at line 439
public additional_checks()

Performing additional checks