FileUpload::isNull PHP Method

isNull() public method

判断文件实例是否存在
public isNull ( )
    public function isNull()
    {
        //        dump($this->instance);
        if ($this->instance == null) {
            return true;
        }
        return false;
    }

Usage Example

Example #1
0
 public function actionUpdate($id)
 {
     $model = $this->loadBiz(trim($id));
     $model->setScenario('sell');
     $this->performAjaxValidation($model);
     if (!empty($_POST)) {
         $model->attributes = $_POST['ARBiz'];
         //            dump($_FILES);
         //            控制器中使用实例如下:
         $upload = new FileUpload(array($model, 'license_photo'), 'upload/groupon');
         //model处理文件上传  $upload = new FileUpload(array($model,'pic'),'upload/goods');
         if (!$upload->isNull()) {
             if ($filename = $upload->save()) {
                 $model->license_photo = $filename;
                 //                      dump($filename);
             } else {
                 print_r($upload->getErrors());
                 throw new CHttpException('300', '文件上传失败');
             }
         }
         //            dump($model->attributes);
         if ($model->save()) {
             //                $return_url = $_POST['return_url'];
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }
All Usage Examples Of FileUpload::isNull