Not a developer? Go to MovableType.com

Documentation

MT::App::CMS::cmsuploadfile

This callback is invoked just after a file (not an image) has been uploaded. It passes to the handler information about the file that was uploaded so that additional information can be gathered, or additional transformations can be applied to the file.

Input Parameters

  • $cb - a reference to the current MT::Callback object handling this event.
  • $params - a hash ref containing information about the uploaded file.

The following are the keys of the parameter ($params) hash passed into the handler as input:

  • File or file - a link to the file on the filesystem
  • Url or url - the URL to the file
  • Size or size - the size of the file in bytes
  • Asset or asset - a reference to the MT::Asset object
  • Type or type - the type of asset
  • Blog or blog - the blog ID

Return Value

None.

Example Handler

sub handler {
    my ($cb, $params) = @_;
    MT::Log->log({ message => "user uploaded a file at " . $params->{Url} });
}
Back

1 Comment

Stefan Seifarth

Stefan Seifarth on September 12, 2010, 2:43 a.m. Reply

In MT 4.32 the arguments are not stored in a hash ref. all arguments will be given as separate argument. e.g.

arg1: $cb arg2: string “File” arg3: string “/path/to/file” and so on …

the example should be written as this one:

sub handler {
    my $cb = shift;
    my $params = {};
    my $key = '';
    for (my $i = 0; $i < $#_; $i++) {
        if ($i % 2 == 0) {
            $key = $_[$i];
        } else {
            $params->{$key} = $_[$i];
        }
    }
    MT->log({ message => "user uploaded a file at " . $params->{Url}});
}

this documentation is often not updated and not usable for plugin developers.

Leave a Comment