# \cge_uploader

A class to aide in dealing with uploaded files, including post processing of images.

## Summary

Methods
Properties
Constants
set_preview()
set_preview_size()
set_watermark()
set_thumbnail()
set_thumbnail_size()
set_delete_orig()
is_accepted_imagefile()
get_accepted_imagetypes()
set_accepted_imagetypes()
handle_upload()
__construct()
set_preprocessor()
get_accepted_filetypes()
set_accepted_filetypes()
is_accepted_file()
set_max_filesize()
set_allow_overwrite()
get_error()
get_errormsg()
reset_errors()
get_dest_dir()
set_dest_dir()
get_dest_filename()
get_orig_filename()
check_upload_attempted()
check_upload()
No public properties found
NOFILE
FILESIZE
FILETYPE
FILEEXISTS
BADDESTDIR
BADPERMS
MOVEFAILED
UPLOADFAILED
PREPROCESSING_FAILED
preprocess_upload()
set_errno()
set_error()
No protected properties found
N/A
No private methods found
No private properties found
N/A

File
  lib/class.cge_uploader.php
Package
  \CGExtensions
Class hierarchy
  \cg_fileupload
  \cge_uploader

## Tags

todo |

## Constants

### NOFILE

    NOFILE

#

Inherited from
  \cg_fileupload

## Tags

todo |

### FILESIZE

    FILESIZE

#

Inherited from
  \cg_fileupload

## Tags

todo |

### FILETYPE

    FILETYPE

#

Inherited from
  \cg_fileupload

## Tags

todo |

### FILEEXISTS

    FILEEXISTS

#

Inherited from
  \cg_fileupload

## Tags

todo |

### BADDESTDIR

    BADDESTDIR

#

Inherited from
  \cg_fileupload

## Tags

todo |

### BADPERMS

    BADPERMS

#

Inherited from
  \cg_fileupload

## Tags

todo |

### MOVEFAILED

    MOVEFAILED

#

Inherited from
  \cg_fileupload

## Tags

todo |

### UPLOADFAILED

    UPLOADFAILED

#

Inherited from
  \cg_fileupload

## Tags

todo |

### PREPROCESSING_FAILED

    PREPROCESSING_FAILED

#

Inherited from
  \cg_fileupload

## Tags

todo |

## Methods

### set_preview()

    set_preview(bool $flag)

Set a flag indicating that a preview (slightly larger than a thumbnail) image should be generated from an uploaded image.

#### Parameters

bool | $flag |

#

## Tags

todo |

### set_preview_size()

    set_preview_size(int $size)

Set the size (in pixels) of the preview image.

This is only applicable if preview is enabled.

#### Parameters

int | $size |

#

## Tags

todo |

### set_watermark()

    set_watermark(bool $flag)

Set a flag indicating that an uploaded image should be watermarked.

#### Parameters

bool | $flag |

#

## Tags

todo |

### set_thumbnail()

    set_thumbnail(bool $flag)

Set a flag indicating that a thumbnail should be generated from an uploaded image.

#### Parameters

bool | $flag |

#

## Tags

todo |

### set_thumbnail_size()

    set_thumbnail_size(int $size)

Set the size (in pixels) of the generated thumbnails.

#### Parameters

int | $size |

#

## Tags

todo |

### set_delete_orig()

    set_delete_orig(bool $flag)

Set a flag to indicate that the original file should be deleted after processing.

#### Parameters

bool | $flag |

#

## Tags

todo |

### is_accepted_imagefile()

    is_accepted_imagefile(string $filename) : bool

Test wether the filename specified is a file acceptable for processing.

#### Parameters

string | $filename |

#### Returns

bool

#

## Tags

todo |

### get_accepted_imagetypes()

    get_accepted_imagetypes() : string[]

Return a list of the file extensions that will be accepted for processing on upload.

#### Returns

string[]

#

## Tags

todo |

### set_accepted_imagetypes()

    set_accepted_imagetypes(string|string[] $imagetypes)

Set the list of file extensions that will be accepted for processing on upload.

#### Parameters

string|string[] | $imagetypes | Either an array or a comma delimited list of file extensions.

#

## Tags

todo |

### handle_upload()

    handle_upload(string $name, string $destfilename, string $subfield) : bool

Handle preprocessing an uploaded file, test for errors and move the file to its destination location.

#### Parameters

string | $name | The upload key name
string | $destfilename | An optional destination filename.
string | $subfield | Assume that the prefix+field name represent an array

#### Returns

bool —

True on success, false on error.

#

Inherited from
  \cg_fileupload

## Tags

todo |

### __construct()

    __construct(string $prefix, string $destdir)

Constructor

#### Parameters

string | $prefix | A common array key prefix for all files to be handled by this object.
string | $destdir | The full path to the destination directory.

#

Inherited from
  \cg_fileupload

## Tags

todo |

### set_preprocessor()

    set_preprocessor(callable $func)

Set a preprocessor object

#### Parameters

callable | $func |

#

Inherited from
  \cg_fileupload

## Tags

todo |

### get_accepted_filetypes()

    get_accepted_filetypes()

Return the list of accepted file extensions

#

Inherited from
  \cg_fileupload

## Tags

preturn | string[]
todo |

### set_accepted_filetypes()

    set_accepted_filetypes(mixed $filetypes)

Set the list of accepted file extensions

#### Parameters

mixed | $filetypes | Accepts an array of strings, or a comma separated list of strings.

#

Inherited from
  \cg_fileupload

## Tags

todo |

### is_accepted_file()

    is_accepted_file(string $filename) : bool

Test if the specified filename is among the accepted filetypes

#### Parameters

string | $filename |

#### Returns

bool

#

Inherited from
  \cg_fileupload

## Tags

todo |

### set_max_filesize()

    set_max_filesize(int $size)

Set the maximum file size for uploaded files (in kilobytes).

This method has no effect on the php.ini settings.

#### Parameters

int | $size |

#

Inherited from
  \cg_fileupload

## Tags

todo |

### set_allow_overwrite()

    set_allow_overwrite(bool $flag)

Set a flag that indicates wether overwriting existing files is permitted.

#### Parameters

bool | $flag |

#

Inherited from
  \cg_fileupload

## Tags

todo |

### get_error()

    get_error() : string

Get any error code returned after handling the upload.

See the error codes contained in this string.

#### Returns

string

#

Inherited from
  \cg_fileupload

## Tags

todo |

### get_errormsg()

    get_errormsg() : string

Return a human readable message pertaining to any error code returned after handling the upload.

#### Returns

string

#

Inherited from
  \cg_fileupload

## Tags

todo |

### reset_errors()

    reset_errors()

Reset any errors

#

Inherited from
  \cg_fileupload

## Tags

todo |

### get_dest_dir()

    get_dest_dir() : string

Return the destination directory for uploaded files

#### Returns

string

#

Inherited from
  \cg_fileupload

## Tags

todo |

### set_dest_dir()

    set_dest_dir(string $dir)

Set the destination directory for uploaded files

#### Parameters

string | $dir | The destination directory

#

Inherited from
  \cg_fileupload

## Tags

todo |

### get_dest_filename()

    get_dest_filename() : string

Get the optional destination filename. If any has been specified.

#### Returns

string

#

Inherited from
  \cg_fileupload

## Tags

todo |

### get_orig_filename()

    get_orig_filename()

Get the original filename.

This method is only useful after handle_upload has been called.

#

Inherited from
  \cg_fileupload

## Tags

todo |

### check_upload_attempted()

    check_upload_attempted(string $name, string $subfield) : bool

Check if a file has been uploaded with the specified field name.

If specified in the constructor a prefix will be prepended to this name for comparison. This method will not set any of the error members in the object.

#### Parameters

string | $name | The field name
string | $subfield | Assume that the prefix+field name represent an array

#### Returns

bool

#

Inherited from
  \cg_fileupload

## Tags

todo |

### check_upload()

    check_upload(string $name, string $subfield, bool $checkdir) : bool

Check if a file has been uploaded to the specified name, and if it is valid.

If specified in the constructor a prefix will be prepended to this name for comparison. This method will set internal error strings and numbers on failure.

#### Parameters

string | $name | The upload key name
string | $subfield | Assume that the prefix+field name represent an array
bool | $checkdir | Test if the destination directory exists, and is writable.

#### Returns

bool —

True on success, false on error.

#

Inherited from
  \cg_fileupload

## Tags

todo |

### preprocess_upload()

    preprocess_upload(array $fileinfo) : string

Preprocess the uploaded file.

If a preprocessor has been passed into this object, this method will preprocess the file

#### Parameters

array | $fileinfo | The file info record (from the $_FILES array) for the file to preprocess.

#### Returns

string —

The filename of the pre-processed file on success. Otherwise, FALSE

#

Inherited from
  \cg_fileupload

## Tags

todo |

### set_errno()

    set_errno(string $val)

Set the current error code See error codes defined above.

#### Parameters

string | $val |

#

Inherited from
  \cg_fileupload

## Tags

todo |

### set_error()

    set_error(string $val)

Set a human readable error message.

#### Parameters

string | $val |

#

Inherited from
  \cg_fileupload

## Tags

todo |

### class.cge_uploader.php