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


PHP UploadedFile::getInstance方法代码示例

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


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

示例1: getImageOriginal

 public function getImageOriginal()
 {
     if (file_exists($this->pathForIcons . "/apple-icon-original.png")) {
         $this->imageOriginal = UploadedFile::getInstance($model, 'imageOriginal');
     }
     return $this->imageOriginal;
 }
开发者ID:Elgorm,项目名称:apple-touch-icon,代码行数:7,代码来源:Icon.php

示例2: actionUpload

 public function actionUpload()
 {
     $model = new UploadForm();
     if (Yii::$app->request->isPost) {
         $tanggal = date("YmdHis");
         $model->file = UploadedFile::getInstance($model, 'file');
         if ($model->file && $model->validate()) {
             $model->file->saveAs('uploads/data_prospek/' . $model->file->baseName . $tanggal . '.' . $model->file->extension);
             //$this->actionExupload();
         }
     }
     return $this->render('upload', ['model' => $model]);
 }
开发者ID:agungsuprayitno,项目名称:sme,代码行数:13,代码来源:TrunkController.php

示例3: actionCreate

 public function actionCreate()
 {
     $model = new MeForm();
     if ($model->load(Yii::$app->request->post())) {
         $model->file = UploadedFile::getInstance($model, 'file');
         $photoName = 'uploads/' . $model->title . '.' . $model->file->extension;
         $model->file->saveAs($photoName);
         $model->photo = $photoName;
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:aversilov,项目名称:singree-bboard,代码行数:14,代码来源:MeController.php

示例4: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $model = $this->model;
     if ($model->load($_POST)) {
         $file = UploadedFile::getInstance($model, 'file');
         $model->fileName = $file->getBaseName() . '.' . $file->getExtension();
         if ($model->validate()) {
             $uploaded = $file->saveAs(Yii::getAlias('@app/web/imgs') . "/{$model->path}");
         } else {
             print_r($model->getErrors());
         }
     }
     Yii::$app->response->format = Response::FORMAT_JSON;
     return ['files' => [['url' => "/imgs/{$model->path}", 'name' => 'name', 'type' => 'type', 'size' => 18932, 'deleteUrl' => 'url', 'deleteType' => 'DELETE']]];
 }
开发者ID:roman444uk,项目名称:yii2,代码行数:18,代码来源:UploadAction.php

示例5: saveUploadedFile

 public function saveUploadedFile($model, $attribute, $fileName = null, $obj = false, $returnObj = false)
 {
     $result = UploadedFile::getInstance($model, $attribute);
     if ($fileName == null) {
         $fileName = time() . '.' . $result->getExtension();
     }
     if (strpos($fileName, "/") !== false) {
         $fileSubPath = substr($fileName, 0, strrpos($fileName, "/"));
         if (!is_dir($this->basePath . '/' . $fileSubPath)) {
             mkdir($this->basePath . '/' . $fileSubPath, $this->filePermission, true);
         }
     }
     if ($result->saveAs($this->basePath . "/" . $fileName)) {
         chmod($this->basePath . "/" . $fileName, $this->filePermission);
     }
     return $returnObj ? $returnObj : $fileName;
 }
开发者ID:ruxon,项目名称:framework,代码行数:17,代码来源:BucketFileSystem.class.php

示例6: actionUpdate

 /**
  * Updates an existing News model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $form = new UploadForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($form->image = UploadedFile::getInstance($form, 'image')) {
             $model->pic = 'image/' . md5($_SERVER['REQUEST_TIME'] . $form->image->baseName) . $_SERVER['REQUEST_TIME'] . '.' . $form->image->extension;
             $form->image->saveAs($model->pic);
         }
         if ($model->type != 4) {
             $model->pic = '';
         }
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'uploadForm' => $form]);
     }
 }
开发者ID:xiaoliwang,项目名称:yii2,代码行数:24,代码来源:NewsController.php


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