本文整理匯總了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 . "*";
}
}