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


PHP FileHelper::getFilePath方法代码示例

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


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

示例1: actionPost

 public function actionPost()
 {
     $model = new PostResumeForm(Yii::app()->user->id);
     //check max job post
     if ($model->getCountUserJobs() < Yii::app()->params['maxResumeJobTitles']) {
         if (isset($_POST['PostResumeForm'])) {
             $model->attributes = $_POST['PostResumeForm'];
             $model->resumeFile = CUploadedFile::getInstance($model, 'resumeFile');
             $model->portfolioFile = CUploadedFile::getInstance($model, 'portfolioFile');
             if ($model->validate()) {
                 //checks the number of job titles submitted are within the limit boundry
                 if (count($model->jobTitles) + $model->getCountUserJobs() > Yii::app()->params['maxResumeJobTitles']) {
                     Yii::app()->user->setFlash('warning', sprintf(Yii::t('app', 'msg.warning.max_job_titles_exceed'), Yii::app()->params['maxResumeJobTitles']));
                     $this->redirect(Yii::app()->createAbsoluteUrl($this->getModule()->returnUrl));
                     Yii::app()->end();
                     return;
                 }
                 $extension = FileHelper::getExtension($model->resumeFile->name);
                 if (!empty($model->portfolioFile->name)) {
                     $extension_PortFolio = FileHelper::getExtension($model->portfolioFile->name);
                 } else {
                     $extension_PortFolio = "";
                 }
                 //saved file name in the following pattern
                 // {user_id}cv{time_stamp_string}.{extension}
                 $fileName = Yii::app()->user->id . 'cv' . Yii::app()->dateFormatter->format('yyyy-MM-dd_H-mm-ss', time()) . '.' . $extension;
                 if (!empty($extension_PortFolio)) {
                     $fileName_PortFolio = Yii::app()->user->id . 'pf' . Yii::app()->dateFormatter->format('yyyy-MM-dd_H-mm-ss', time()) . '.' . $extension_PortFolio;
                 } else {
                     $fileName_PortFolio = "";
                 }
                 if ($model->save(Yii::app()->user->id, $fileName, $fileName_PortFolio)) {
                     //if(!empty($fileName_PortFolio))
                     //{
                     $userFilePath = FileHelper::getFilePath(Yii::getPathOfAlias('site.files') . '/resumes/' . Yii::app()->user->id . '/');
                     $model->resumeFile->saveAs($userFilePath . $fileName);
                     if (!empty($fileName_PortFolio)) {
                         $model->portfolioFile->saveAs($userFilePath . $fileName_PortFolio);
                     }
                     Yii::app()->user->setFlash('success', Yii::t('app', 'msg.success.post_resume'));
                     //}
                 }
                 //checks the number of job titles submitted are within the limit boundry
                 if (count($model->jobTitles) + $model->getCountUserJobs() > Yii::app()->params['maxResumeJobTitles']) {
                     $this->refresh(true);
                 } else {
                     $this->redirect($this->createAbsoluteUrl('index'));
                 }
             }
         }
         $this->render('post', array('model' => $model));
     } else {
         Yii::app()->user->setFlash('warning', sprintf(Yii::t('app', 'msg.warning.max_job_titles_exceed'), Yii::app()->params['maxResumeJobTitles']));
         $this->redirect(Yii::app()->createAbsoluteUrl($this->getModule()->returnUrl));
     }
 }
开发者ID:aakbar24,项目名称:CollegeCorner_Ver_2.0,代码行数:56,代码来源:ResumePostController.php

示例2: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = new WorkshopForm('view', $id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['WorkshopForm'])) {
         $model->attributes = $_POST['WorkshopForm'];
         $model->postItem->attributes = $_POST['PostItem'];
         $model->workshop->attributes = $_POST['Workshop'];
         $model->workshopFile = CUploadedFile::getInstance($model, 'workshopFile');
         Yii::log(CVarDumper::dumpAsString($model->workshopFile));
         if ($model->validate()) {
             $fileUpload = $model->workshopFile;
             if ($fileUpload !== null) {
                 $model->workshop->removeFile();
                 $model->workshop->workshop_file = $fileUpload;
                 $fileName = $fileUpload->name;
             }
             if ($model->save()) {
                 if ($model->workshop->workshop_file !== null) {
                     $userFilePath = FileHelper::getFilePath(Yii::getPathOfAlias('site.files') . '/workshops/' . $model->postItem->primaryKey . '/');
                     $model->workshopFile->saveAs($userFilePath . $fileName);
                 }
                 $this->redirect(array('view', 'id' => $model->workshop->post_item_id));
             }
         }
     }
     $this->render('update', array('model' => $model));
 }
开发者ID:aakbar24,项目名称:CollegeCorner_Ver_2.0,代码行数:34,代码来源:WorkshopController.php


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