當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。