本文整理匯總了PHP中UploadBase::checkFileExtension方法的典型用法代碼示例。如果您正苦於以下問題:PHP UploadBase::checkFileExtension方法的具體用法?PHP UploadBase::checkFileExtension怎麽用?PHP UploadBase::checkFileExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UploadBase
的用法示例。
在下文中一共展示了UploadBase::checkFileExtension方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: verify
/**
* Verifies that it's ok to include the uploaded file
*
* @param string $tmpfile the full path opf the temporary file to verify
* @param string $extension The filename extension that the file is to be served with
* @return Status object
*/
function verify($tmpfile, $extension)
{
# magically determine mime type
$magic = MimeMagic::singleton();
$mime = $magic->guessMimeType($tmpfile, false);
# check mime type, if desired
global $wgVerifyMimeType;
if ($wgVerifyMimeType) {
# check mime type against file extension
if (!UploadBase::verifyExtension($mime, $extension)) {
return Status::newFatal('uploadcorrupt');
}
# check mime type blacklist
global $wgMimeTypeBlacklist;
if (isset($wgMimeTypeBlacklist) && !is_null($wgMimeTypeBlacklist) && UploadBase::checkFileExtension($mime, $wgMimeTypeBlacklist)) {
return Status::newFatal('badfiletype', htmlspecialchars($mime));
}
}
# check for htmlish code and javascript
if (UploadBase::detectScript($tmpfile, $mime, $extension)) {
return Status::newFatal('uploadscripted');
}
/**
* Scan the uploaded file for viruses
*/
$virus = UploadBase::detectVirus($tmpfile);
if ($virus) {
return Status::newFatal('uploadvirus', htmlspecialchars($virus));
}
wfDebug(__METHOD__ . ": all clear; passing.\n");
return Status::newGood();
}