System:File:upload

From Aspen Documentation

Uploads files from an html input element to a server directory. The server path must be set by the upload_server_path configuration.

Since 1.0

Contents

Arguments

array upload ([string $form_field = false], [boolean $overwrite = false], [boolean $timestamp = true], [string $rename = false])


form_field
Name of html input file information is coming from.
overwrite
Toggles overwriting existing files. If false, and previous filename exists, an error will be returned.
timestamp
Whether or not to append a timestamp to the filename, between the name and the extension.
rename
A specific name to rename the file to.

Returns

Returns an array of file information, or false on error.

Notes

  • The class will handle an array of files.

Examples

The following code will upload files sent from a form with a file input field called "inputfilename".

$this->APP->file->upload('inputfilename');

If successful, an array will be returned:

Array
(
    [0] => Array
        (
            [upload_directory] => /path/to/uploads
            [upload_success] => 1
            [server_file_path] => /path/to/uploads/walle2a.20090320-1235.jpg
            [browser_file_path] => http://yourdomain.com/uploads/walle2a.20090320-1235.jpg
            [file_name] => walle2a.20090320-1235.jpg
            [file_type] => application/octet-stream
            [file_size] => 30470
            [file_extension] => .jpg
            [upload_timestamp] => 2009-03-20 12:35:15
        )

)