SproutCMS

This is the code documentation for the SproutCMS project

function verify()

Verify that the temporary file specified by the user exists and has valid content,
and that the original file name is acceptable
This is to be used during form processing upon a POST submission.

Usage

string FileUpload::verify ( string $sess_key , string $field , int $index , array $allowed_exts );

Example

// Expects $_POST['avatar'][0] and $_POST['avatar_temp'][0] to both be set
// Expects $_SESSION['file_uploads']['user_details']['avatar']['code'] to be set
$result = FileUpload::verify('user_details', 'avatar', 0, ['jpg', 'gif', 'png']);
// Result will be something like '/home/.../sprout/temp/xxxx'

Arguments

  1. string $sess_key
    Session key related to the form, e.g. 'user-register';
           see $params['sess_key'] of Fb::chunkedUpload
  2. string $field
    Name of field to process, e.g. 'image'
  3. int $index
    Array index; 0 for the first file, 1 for the next and so on
  4. array $allowed_exts
    Array of string file-types that are allowed

Exceptions thrown

  • DomainException
    If the $_POST upload state is invalid.
  • FileUploadException
    If there was an issue the uploader should know about, e.g. the file extension isn't permitted.
                                This exception always has front-end safe exception messages.

Return value

  • string
    Path to temporarily uploaded file; this can be used as the first argument to
            File::moveUpload to put the file in the desired permanent location.