当前位置: 首页>>代码示例>>PHP>>正文


PHP UploadedFile::saveAs方法代码示例

本文整理汇总了PHP中yii\web\UploadedFile::saveAs方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadedFile::saveAs方法的具体用法?PHP UploadedFile::saveAs怎么用?PHP UploadedFile::saveAs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\web\UploadedFile的用法示例。


在下文中一共展示了UploadedFile::saveAs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     $this->preview_input = UploadedFile::getInstance($this, 'preview_input');
     if (!empty($this->preview_input)) {
         $this->preview_input->saveAs($this->preview_picture);
     }
     parent::afterSave($insert, $changedAttributes);
 }
开发者ID:amarchenkov,项目名称:myCMS,代码行数:8,代码来源:Article.php

示例2: upload

 public function upload()
 {
     if ($this->validate()) {
         $this->excelFile->saveAs(Yii::$app->basePath . '/uploads/' . $this->excelFile->baseName . '.' . $this->excelFile->extension);
         return true;
     } else {
         return false;
     }
 }
开发者ID:Polymedia,项目名称:BI-Platform-v3,代码行数:9,代码来源:ExcelUploadForm.php

示例3: upload

 public function upload()
 {
     if ($this->validate()) {
         $this->IMAGE->saveAs('upload/' . $this->IMAGE->baseName . '.' . $this->IMAGE->extension);
         return true;
     } else {
         return false;
     }
 }
开发者ID:adem-team,项目名称:advanced,代码行数:9,代码来源:Barangumumupload.php

示例4: uploadImage

 public function uploadImage()
 {
     if ($this->validate() && $this->imageFile) {
         $this->imageFile->saveAs(Yii::getAlias("@webroot") . '/uploads/' . $this->imageFile->baseName . '.' . $this->imageFile->extension);
         return true;
     } else {
         return false;
     }
 }
开发者ID:RStuffGit,项目名称:mebel,代码行数:9,代码来源:Goods.php

示例5: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     if ($this->scenario == self::SCENARIO_FILE_UPLOAD) {
         $fileName = $this->getFileName();
         FileHelper::createDirectory(dirname($fileName));
         $this->fileUpload->saveAs($fileName);
     }
     parent::afterSave($insert, $changedAttributes);
 }
开发者ID:omnilight,项目名称:yii2-models,代码行数:9,代码来源:File.php

示例6: beforeSave

 /**
  * @inherited
  */
 public function beforeSave($insert)
 {
     if ($this->file && $this->file instanceof UploadedFile && parent::beforeSave($insert)) {
         FileHelper::createDirectory(dirname($this->filename));
         return $this->file->saveAs($this->filename, false);
     }
     return false;
 }
开发者ID:kotmonstr,项目名称:kotmonstr,代码行数:11,代码来源:FileModel.php

示例7: upload

 public function upload()
 {
     if ($this->validate()) {
         $this->imageFile->saveAs('img/' . $this->imageFile->baseName . '.' . $this->imageFile->extension);
         return true;
     } else {
         return false;
     }
 }
开发者ID:bishabosha,项目名称:flair,代码行数:9,代码来源:UploadForm.php

示例8: upload

 public function upload()
 {
     if ($this->validate()) {
         $this->filename = \Yii::$app->security->generateRandomString() . '.' . $this->file->extension;
         $this->file->saveAs("uploads/{$this->filename}");
         return true;
     }
     return false;
 }
开发者ID:eugenrein,项目名称:koios,代码行数:9,代码来源:UploadForm.php

示例9: upload

 public function upload()
 {
     if ($this->validate()) {
         //yii::setAlias('@path1', 'localhost/basic/');
         $this->imageFile->saveAs(\Yii::$app->basePath . '/uploads/' . $this->imageFile->baseName . '.' . $this->imageFile->extension);
         return true;
     } else {
         return false;
     }
 }
开发者ID:billcccheng,项目名称:Yii2-Basic,代码行数:10,代码来源:UploadForm.php

示例10: upload

 public function upload()
 {
     $file_path = \Yii::getAlias('@upload');
     if ($this->validate()) {
         $this->file->saveAs($file_path . $this->file->baseName . '.' . $this->file->extension);
         return true;
     } else {
         return false;
     }
 }
开发者ID:havennow,项目名称:sageone_test,代码行数:10,代码来源:UploadForm.php

示例11: upload

 public function upload()
 {
     $uid = Yii::$app->user->getId();
     if ($this->validate()) {
         $path = 'uploads/excels/' . $uid . '_' . time() . '.' . $this->excelFile->extension;
         $this->excelFile->saveAs($path);
         return $path;
     } else {
         return false;
     }
 }
开发者ID:realphp,项目名称:yii2-admin,代码行数:11,代码来源:UploadForm.php

示例12: upload

 /**
  * @return null|string
  */
 public function upload()
 {
     if ($this->validate()) {
         $fileName = $this->imageFile->baseName . '.' . $this->imageFile->extension;
         $filePath = __DIR__ . '../../web/files/' . $fileName;
         $this->imageFile->saveAs($filePath);
         return $filePath;
     } else {
         return null;
     }
 }
开发者ID:7lion,项目名称:testProject,代码行数:14,代码来源:ConvectorForm.php

示例13: upload

 /**
  * @return bool
  */
 public function upload()
 {
     if ($this->validate()) {
         return $this->file->saveAs($this->getPath(), true);
     }
     return false;
 }
开发者ID:apurey,项目名称:cmf,代码行数:10,代码来源:FileUploadModel.php

示例14: upload

 public function upload()
 {
     if ($this->validate()) {
         return $this->file->saveAs(Yii::$app->controller->module->getFilePath($this->getFileName()), true);
     }
     return false;
 }
开发者ID:kintastish,项目名称:mobil,代码行数:7,代码来源:FileUploadModel.php

示例15: upload

 public function upload()
 {
     if ($this->imageFile = UploadedFile::getInstance($this, 'imageFile')) {
         $this->preview = md5($this->imageFile->baseName . time()) . '.' . $this->imageFile->extension;
         $this->imageFile->saveAs(Yii::getAlias('@webroot') . '/' . self::UPLOAD_DIR . $this->preview);
         $this->imageFile = NULL;
         Image::thumbnail('@webroot/' . self::UPLOAD_DIR . $this->preview, 120, 120)->save(Yii::getAlias('@webroot') . '/' . self::UPLOAD_DIR . 'thumb/' . $this->preview, ['quality' => 80]);
     }
 }
开发者ID:Everus,项目名称:rgk_test,代码行数:9,代码来源:Books.php


注:本文中的yii\web\UploadedFile::saveAs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。