MT::App::CMS::cms_upload_file

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} });
}
This page was last updated on 2008-10-01, 17:03.

1 Note

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 {$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 note

Have a question? Please use the MT Forums. Notes submitted on documentation should pertain to tips & hints regarding documentation. Your note may be removed once its contents have been integrated into the body of the page.