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


PHP UploadedFile::getBaseName方法代碼示例

本文整理匯總了PHP中yii\web\UploadedFile::getBaseName方法的典型用法代碼示例。如果您正苦於以下問題:PHP UploadedFile::getBaseName方法的具體用法?PHP UploadedFile::getBaseName怎麽用?PHP UploadedFile::getBaseName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\web\UploadedFile的用法示例。


在下文中一共展示了UploadedFile::getBaseName方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: saveData

 /**
  * @param \yii\web\UploadedFile $file
  *
  * @return int
  */
 public function saveData(\yii\web\UploadedFile $file)
 {
     $ext = $file->getExtension();
     $baseName = $file->getBaseName();
     $model = new \metalguardian\fileProcessor\models\File();
     $model->extension = $ext;
     $model->base_name = $baseName;
     $model->save(false);
     return $model->id;
 }
開發者ID:hanterrian,項目名稱:yii2-file-processor-module,代碼行數:15,代碼來源:FileTransfer.php

示例2: beforeSave

 /**
  * Before save event.
  *
  * @throws \yii\base\InvalidConfigException
  */
 public function beforeSave()
 {
     if ($this->file instanceof UploadedFile) {
         $this->_filePath = $this->resolvePath($this->filePath);
         $owner = $this->owner;
         $owner->{$this->attribute} = str_replace($this->_rootPath, '', $this->_filePath);
         if ($this->filenameAttribute && empty($owner->{$this->filenameAttribute})) {
             $owner->{$this->filenameAttribute} = $this->file->getBaseName();
         }
     }
 }
開發者ID:hiscaler,項目名稱:yii2-file-upload-behaviors,代碼行數:16,代碼來源:ImageUploadBehavior.php

示例3: createFromUploadedFile

 public static function createFromUploadedFile(UploadedFile $file)
 {
     $upload = new static();
     $upload->mimetype = FileHelper::getMimeType($file->tempName);
     $upload->checksum = hash_file('sha256', $file->tempName);
     $upload->filename = $file->getBaseName() . '.' . $file->getExtension();
     $upload->filesize = $file->size;
     $upload->createContainerDir();
     $file->SaveAs($upload->getContainerDir() . '/' . $upload->filename);
     $upload->save();
     return $upload;
 }
開發者ID:joorloohuis,項目名稱:bat-web-frontend,代碼行數:12,代碼來源:Upload.php

示例4: uploadPhoto

 /**
  * Загрузка изображения.
  *
  * @param UploadedFile $uploadedFile
  * @param $userId
  * @return bool
  */
 public function uploadPhoto(UploadedFile $uploadedFile, $userId)
 {
     if ($uploadedFile->getBaseName() && !$uploadedFile->getHasError()) {
         $photoName = 'profile_photo_' . $userId . '.' . $uploadedFile->getExtension();
         $photoSaveFolder = \Yii::getAlias('@app') . $this->profilePhotoFolder . '/' . $userId;
         if (!file_exists($photoSaveFolder)) {
             mkdir($photoSaveFolder);
         }
         $photoPath = $photoSaveFolder . '/' . $photoName;
         $uploadedFile->saveAs($photoPath);
         return $photoName;
     }
     return false;
 }
開發者ID:vlamug,項目名稱:landing-page-crm,代碼行數:21,代碼來源:PhotoManagerComponent.php

示例5: runForFile

 /**
  * @param UploadedFile $uploadedFile
  *
  * @return bool|string
  */
 public function runForFile(UploadedFile $uploadedFile)
 {
     $extension = $uploadedFile->getExtension();
     $baseName = $uploadedFile->getBaseName();
     if ($this->useMd5Names) {
         $filename = sprintf('%s', md5(time() . $baseName));
     } elseif (is_null($this->customName) == false) {
         $filename = sprintf("%s", $this->customName);
     } else {
         $filename = sprintf("%s", $baseName);
     }
     $filename = $this->getUniqueFilename($filename, $extension);
     $filePath = $this->getFilePath($filename);
     if ($uploadedFile->saveAs($filePath)) {
         return $filename;
     }
     return false;
 }
開發者ID:pbabilas,項目名稱:bcode,代碼行數:23,代碼來源:Uploader.php

示例6: saveUploaded

 protected function saveUploaded(UploadedFile $file)
 {
     $dir = $this->getPath(false, true);
     $file_name = $file->getBaseName();
     $file_ext = $file->getExtension();
     $filename = $file_name . '.' . $file_ext;
     $index = 0;
     while (file_exists($dir . $filename)) {
         $index++;
         $filename = $file_name . '-' . $index . '.' . $file_ext;
     }
     FileHelper::createDirectory($dir, 0777, true);
     $path = $dir . $filename;
     if ($file->saveAs($path)) {
         return [$filename, filesize($path)];
     }
     return false;
 }
開發者ID:vsguts,項目名稱:crm,代碼行數:18,代碼來源:Attachment.php

示例7: getFileName

 /**
  * @param UploadedFile $file
  * @param callable $formatFileName
  * @return string
  */
 protected function getFileName(UploadedFile $file, \Closure $formatFileName = null)
 {
     $filename = $file->name;
     if (!is_null($formatFileName)) {
         $filename = call_user_func($formatFileName, $file->getBaseName(), $file->getExtension());
     }
     return $filename;
 }
開發者ID:opus-online,項目名稱:yii2-file,代碼行數:13,代碼來源:UploadHandler.php

示例8: saveUploaded

 protected function saveUploaded(UploadedFile $image)
 {
     $dir = $this->getPath(false, false, true);
     $image_name = $image->getBaseName();
     $image_ext = $image->getExtension();
     $filename = $image_name . '.' . $image_ext;
     $index = 0;
     while (file_exists($dir . $filename)) {
         $index++;
         $filename = $image_name . '-' . $index . '.' . $image_ext;
     }
     $path = $dir . $filename;
     $this->createFileDir($path);
     if ($image->saveAs($path)) {
         return $filename;
     }
     return false;
 }
開發者ID:vsguts,項目名稱:crm,代碼行數:18,代碼來源:Image.php


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