當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UploadFile::getFilename方法代碼示例

本文整理匯總了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;
 }
開發者ID:nick-strohm,項目名稱:WCF,代碼行數:19,代碼來源:DefaultUploadFileValidationStrategy.class.php

示例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 . "*";
             }
         }
開發者ID:sabalbhati,項目名稱:DiscoverMoreMusic,代碼行數:31,代碼來源:registration_validation.php


注:本文中的UploadFile::getFilename方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。