Manual:Hooks/UploadVerifyFile

From MediaWiki.org
Jump to: navigation, search
UploadVerifyFile
Available from version 1.17.0
Called when a file is uploaded, to allow extra file verification to take place
Define function:
public static function onUploadVerifyFile( $upload, $mime, &$error ) { ... }
Attach hook:
$wgHooks['UploadVerifyFile'][] = 'MyExtensionHooks::onUploadVerifyFile';
Called from: File(s): UploadBase.php
Function(s): UploadBase::verifyFile()

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:UploadVerifyFile extensions.

Details[edit]

  • $upload: an instance of UploadBase, with all info about the upload
  • $mime: the uploaded file's mime type, as detected by MediaWiki. Handlers will typically only apply for specific mime types.
  • &$error: output: true if the file is valid. Otherwise, an indexed array representing the problem with the file, where the first element is the message key and the remaining elements are used as parameters to the message.