error() protected méthode

+---------------------------------------------------------- 获取错误代码信息 +---------------------------------------------------------- +----------------------------------------------------------
protected error ( string $errorNo )
$errorNo string 错误号码 +---------------------------------------------------------- +----------------------------------------------------------
Exemple #1
0
 /**
  * 添加/修改文章
  */
 public function save()
 {
     if (!empty($_POST['id']) && !ctype_digit($_POST['id'])) {
         $this->failure(Core::getLang('invalid_request'));
     }
     // 如果有文件上传
     if ($_FILES['title_image']['error'] != UPLOAD_ERR_NO_FILE) {
         $options = array('type' => 'image', 'max_size' => 1024000, 'save_path' => IMG_PATH . 'article/', 'save_rule' => '##Ymd/');
         $upload = new UploadFile($options);
         // 上传错误提示错误信息
         if (!$upload->upload()) {
             $this->failure($upload->error());
         } else {
             // 上传成功 获取上传文件信息
             $_POST['title_image'] = $upload->fileList['title_image']['savename'];
         }
     } else {
         $_POST['title_image'] = '';
     }
     $_POST['editor_uid'] = $_SESSION['uid'];
     $_POST['editor'] = $_SESSION['username'];
     $_POST['post_time'] = strtotime($_POST['post_time']);
     // 		if (!isset($_POST['brief'])) {
     // 			$_POST['brief'] = '';
     // 		}
     // 		$_POST['content'] = '';
     $mo = new Model_Article();
     if ($mo->save($_POST)) {
         $this->success(Core::getLang('handle_success'), 'admin.php?a=article');
     } else {
         if ($mo->msg) {
             $msg = $mo->msg;
         } else {
             $msg = Core::getLang('save_article_data_fail');
         }
         $this->failure($msg);
     }
 }
Exemple #2
0
<?php

//如果有文件上传
if ($_FILES['image']['error'] != UPLOAD_ERR_NO_FILE || $_FILES['title_image']['error'] != UPLOAD_ERR_NO_FILE) {
    $options = array('type' => 'image', 'max_size' => array('image' => 102400, 'title_image' => 204800), 'save_path' => array('image' => IMG_PATH . 'test/', 'title_image' => IMG_PATH . 'article/'), 'save_rule' => array('image' => '##Ymd/', 'title_image' => ''));
    $upload = new UploadFile($options);
    if (!$upload->upload()) {
        // 上传错误提示错误信息
        $this->json($upload->error(), 0);
    } else {
        // 上传成功 获取上传文件信息
        $_POST['title_image'] = $upload->fileList['title_image']['savename'];
    }
}