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