本文整理汇总了PHP中UploadFile::getFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadFile::getFilename方法的具体用法?PHP UploadFile::getFilename怎么用?PHP UploadFile::getFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadFile
的用法示例。
在下文中一共展示了UploadFile::getFilename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* @see \wcf\system\upload\IUploadFileValidationStrategy::validate()
*/
public function validate(UploadFile $uploadFile)
{
if ($uploadFile->getErrorCode() != 0) {
$uploadFile->setValidationErrorType('uploadFailed');
return false;
}
if ($uploadFile->getFilesize() > $this->maxFilesize) {
$uploadFile->setValidationErrorType('tooLarge');
return false;
}
if (!preg_match($this->fileExtensionRegex, mb_strtolower($uploadFile->getFilename()))) {
$uploadFile->setValidationErrorType('invalidExtension');
return false;
}
return true;
}
示例2: explode
//if password matches the retype, encrypt the user's password
if ($password == $password_again) {
//password encryption
$crypt_password = password_encrypt($password);
} else {
$error_flag++;
}
$temp = explode(".", $_FILES["avatar"]["name"]);
$extension = end($temp);
$destination .= "{$username}\\";
// try to create a new upload object
try {
$upload = new UploadFile($destination, "image");
$upload->setMaxSize($imageMaxSize);
$upload->upload(false);
$filename = $upload->getFilename();
$msgResult = $upload->getmessages();
} catch (Exception $e) {
$msgResult[] = $e->getMessage();
}
//upload user and avatar to db
if ($error_flag == 0) {
$query = "CALL add_user('" . $username . "', '" . $crypt_password . "' ,'" . $filename . "' , '" . $extension . "' , '" . $email . "' , '" . date('Y-m-d') . "' )";
if ($result = $db->query($query)) {
$_SESSION['user'] = $username;
echo "<script> location.href=\"account.php\" </script>";
if (isset($msgResult)) {
foreach ($msgResult as $msg) {
echo $msg . "*";
}
}