Manual:Hooks/UploadVerifyUpload

UploadVerifyUpload
Available from version 1.28.0
Can be used to reject a file upload. Unlike 'UploadVerifyFile' it provides information about upload comment and the file description page, but does not run for uploads to stash.
Define function:
public static function onUploadVerifyUpload( UploadBase $upload, User $user, $props, $comment, $pageText, &$error ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"UploadVerifyUpload": "MediaWiki\\Extension\\MyExtension\\Hooks::onUploadVerifyUpload"
	}
}
Called from: File(s): upload/UploadBase.php
Interface: UploadVerifyUploadHook.php

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


Upload verification, based on both file properties like ​MIME type (same as UploadVerifyFile) and the information entered by the user ​(upload comment, file page contents etc.).

Details

edit
  • UploadBase $upload: An instance of UploadBase, with all info about the upload
  • User $user: An instance of User, the user uploading this file
  • array|null $props: File properties, as returned by MWFileProps::getPropsFromPath(). Note this is not always guaranteed to be set, e.g. in test scenarios. Call MWFileProps::getPropsFromPath() yourself in case you need the information.
  • string $comment: Upload log comment, also used as edit summary
  • string $pageText: File description page text. Only used for new uploads.
  • MessageSpecifier|array|string|null &$error: If the file upload should be prevented, set this output parameter to the reason in the form of array( messagename, param1, param2, … ) or a MessageSpecifier instance. You might want to use ApiMessage to provide machine-readable details for the API.

See also

edit