当前位置: 首页>>代码示例>>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;未经允许,请勿转载。