phpBB API Documentation
Class

fileupload

class fileupload

File upload class Init class (all parameters optional and able to be set/overwritten separately) - scope is global and valid for all uploads

Properties

$allowed_extensions
$disallowed_content
$max_filesize
$min_width
$min_height
$max_width
$max_height
$error_prefix
int $upload_timeout

Methods

fileupload(string $error_prefix = '', array $allowed_extensions = false, int $max_filesize = false, int $min_width = false, int $min_height = false, int $max_width = false, int $max_height = false, bool|array $disallowed_content = false)

Init file upload class.

reset_vars()

Reset vars

set_allowed_extensions($allowed_extensions)

Set allowed extensions

set_allowed_dimensions($min_width, $min_height, $max_width, $max_height)

Set allowed dimensions

set_max_filesize($max_filesize)

Set maximum allowed filesize

set_disallowed_content($disallowed_content)

Set disallowed strings

set_error_prefix($error_prefix)

Set error prefix

object form_upload(string $form_name, guesser $mimetype_guesser = null, plupload $plupload = null)

Form upload method Upload file from users harddisk

local_upload($source_file, $filedata = false, guesser $mimetype_guesser = null)

Move file from another location to phpBB

object remote_upload(string $upload_url, guesser $mimetype_guesser = null)

Remote upload method Uploads file from given url

assign_internal_error($errorcode)

Assign internal error

common_checks($file)

Perform common checks

valid_extension($file)

Check for allowed extension

valid_dimensions($file)

Check for allowed dimension

is_valid($form_name)

Check if form upload is valid

valid_content($file)

Check for bad content (IE mime-sniffing)

static array image_types()

Get image type/extension mapping

Details

at line 518
public fileupload(string $error_prefix = '', array $allowed_extensions = false, int $max_filesize = false, int $min_width = false, int $min_height = false, int $max_width = false, int $max_height = false, bool|array $disallowed_content = false)

Init file upload class.

Parameters

string $error_prefix Used error messages will get prefixed by this string
array $allowed_extensions Array of allowed extensions, for example array('jpg', 'jpeg', 'gif', 'png')
int $max_filesize Maximum filesize
int $min_width Minimum image width (only checked for images)
int $min_height Minimum image height (only checked for images)
int $max_width Maximum image width (only checked for images)
int $max_height Maximum image height (only checked for images)
bool|array $disallowed_content If enabled, the first 256 bytes of the file must not contain any of its values. Defaults to false.

at line 530
public reset_vars()

Reset vars

at line 542
public set_allowed_extensions($allowed_extensions)

Set allowed extensions

Parameters

$allowed_extensions

at line 553
public set_allowed_dimensions($min_width, $min_height, $max_width, $max_height)

Set allowed dimensions

Parameters

$min_width
$min_height
$max_width
$max_height

at line 564
public set_max_filesize($max_filesize)

Set maximum allowed filesize

Parameters

$max_filesize

at line 575
public set_disallowed_content($disallowed_content)

Set disallowed strings

Parameters

$disallowed_content

at line 586
public set_error_prefix($error_prefix)

Set error prefix

Parameters

$error_prefix

at line 602
public object form_upload(string $form_name, guesser $mimetype_guesser = null, plupload $plupload = null)

Form upload method Upload file from users harddisk

Parameters

string $form_name Form name assigned to the file input field (if it is an array, the key has to be specified)
guesser $mimetype_guesser Mimetype guesser
plupload $plupload The plupload object

Return Value

object $file Object "filespec" is returned, all further operations can be done with this object

at line 678
public local_upload($source_file, $filedata = false, guesser $mimetype_guesser = null)

Move file from another location to phpBB

Parameters

$source_file
$filedata
guesser $mimetype_guesser

at line 758
public object remote_upload(string $upload_url, guesser $mimetype_guesser = null)

Remote upload method Uploads file from given url

Parameters

string $upload_url URL pointing to file to upload, for example http://www.foobar.com/example.gif
guesser $mimetype_guesser Mimetype guesser

Return Value

object $file Object "filespec" is returned, all further operations can be done with this object

at line 956
public assign_internal_error($errorcode)

Assign internal error

Parameters

$errorcode

at line 1006
public common_checks($file)

Perform common checks

Parameters

$file

at line 1040
public valid_extension($file)

Check for allowed extension

Parameters

$file

at line 1048
public valid_dimensions($file)

Check for allowed dimension

Parameters

$file

at line 1069
public is_valid($form_name)

Check if form upload is valid

Parameters

$form_name

at line 1081
public valid_content($file)

Check for bad content (IE mime-sniffing)

Parameters

$file

at line 1091
static public array image_types()

Get image type/extension mapping

Return Value

array Array containing the image types and their extensions