當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UploadFile::getErrorNo方法代碼示例

本文整理匯總了PHP中UploadFile::getErrorNo方法的典型用法代碼示例。如果您正苦於以下問題:PHP UploadFile::getErrorNo方法的具體用法?PHP UploadFile::getErrorNo怎麽用?PHP UploadFile::getErrorNo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UploadFile的用法示例。


在下文中一共展示了UploadFile::getErrorNo方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: add

 /**
  * 新增與更新數據
  *@param $act add為新增、edit為編輯
  *@param $go  為1時,獲取post
  *@param $id  傳人數據id
  *@examlpe 
  */
 public function add($act = NULL, $go = false, $id = NULL)
 {
     $app = A('App', 'Public');
     import('ORG.Net.FileSystem');
     $sys = new FileSystem();
     import('ORG.Net.UploadFile');
     $up = new UploadFile();
     $arr_type = C('UPLOAD_TYPE');
     $arr_type = explode(',', $arr_type);
     $up->allowExts = $arr_type;
     $upload = C('TMPL_PARSE_STRING.__UPLOAD__');
     $up->savePath = ROOT . '/' . $upload . '/';
     $up->maxSize = C('UPLOAD_SIZE');
     $up->charset = 'UTF-8';
     $up->autoSub = true;
     $up->allowNull = true;
     //main
     $Bug = D('Bug_table');
     $userid = $_SESSION['login']['se_id'];
     $username = $_SESSION['login']['se_user'];
     if ($go == false) {
         $this->assign('uniqid', uniqid());
         if ($act == 'add') {
             $this->assign('act', 'add');
             $this->display();
         } else {
             if (!is_int((int) $id)) {
                 $id = NULL;
                 $this->show('無法獲取ID');
             } else {
                 $map['id'] = array('eq', $id);
                 $info = $Bug->relation(true)->where($map)->find();
                 $this->assign('constr', $constr);
                 $constr = '';
                 $this->assign('id', $id);
                 $this->assign('act', 'edit');
                 $this->assign('info', $info);
                 $this->display();
                 unset($info, $uinfo, $map);
             }
         }
     } else {
         $data = $Bug->create();
         $content = $_POST['content'];
         $fulltext = strip_tags($content);
         $fulltext = preg_replace("/[\n\r\t\v]/iu", "", $fulltext);
         $fulltext = pinyin($fulltext, ' ');
         $fulltext = preg_replace("/\\s+/u", " ", $fulltext);
         $fulltext = trim($fulltext);
         $solution = $_POST['solution'];
         $data['baseinfo'] = array('content' => $content, 'solution' => $solution);
         $data['fulltext'] = array('content_index' => $fulltext);
         $ischg = 0;
         if ($up->upload()) {
             $info = $up->getUploadFileInfo();
             $data['files'] = $info[0]['savename'];
             $ischg = 1;
         } else {
             $errorNo = $up->getErrorNo();
             if ($errorNo != 2) {
                 echo $info = $up->getErrorMsg();
                 exit;
             }
         }
         if ($act == 'add') {
             $Public = A('Index', 'Public');
             $role = $Public->check('Bug', array('c'));
             if ($role < 0) {
                 echo $role;
                 exit;
             }
             $data['user_id'] = $userid;
             $data['addtime'] = date("Y-m-d H:i:s", time());
             $add = $Bug->relation(true)->add($data);
             if ($add > 0) {
                 echo 1;
             } else {
                 $path = ROOT . '/' . $upload . '/' . $info[0]['savename'];
                 if ($info[0]['savename'] && file_exists($path)) {
                     $sys->delFile($path);
                 }
                 echo 0;
             }
             unset($data, $Public);
         } elseif ($act == 'edit') {
             $Public = A('Index', 'Public');
             $role = $Public->check('Bug', array('u'));
             if ($role < 0) {
                 echo $role;
                 exit;
             }
             if (!is_int((int) $id)) {
                 echo 0;
//.........這裏部分代碼省略.........
開發者ID:huangchuping,項目名稱:bug,代碼行數:101,代碼來源:BugAction.class.php

示例2: upfile

 /**
  * 上傳附件
  *@param $id  數據id值
  *@examlpe 
  */
 public function upfile($id)
 {
     $Public = A('Index', 'Public');
     $Log = A('Log', 'Public');
     $role = $Public->check('Report', array('c'));
     if ($role < 0) {
         echo $role;
         exit;
     }
     import('ORG.Net.FileSystem');
     $sys = new FileSystem();
     import('ORG.Net.UploadFile');
     $up = new UploadFile();
     $arr_type = C('UPLOAD_TYPE');
     $arr_type = explode(',', $arr_type);
     $up->allowExts = $arr_type;
     $upload = C('TMPL_PARSE_STRING.__UPLOAD__');
     $up->savePath = ROOT . '/' . $upload . '/';
     $up->maxSize = C('UPLOAD_SIZE');
     $up->charset = 'UTF-8';
     $up->autoSub = true;
     $up->allowNull = true;
     //main
     $files_table = M('Report_files_table');
     $report_table = M('Report_table');
     $rid = intval($id);
     $uid = $_SESSION['login']['se_id'];
     $username = $_SESSION['login']['se_user'];
     $report = $report_table->where('id=' . $rid)->find();
     if ($up->upload()) {
         $info = $up->getUploadFileInfo();
         $data = array('rid' => $rid, 'user_id' => $uid, 'path' => $info[0]['savename'], 'addtime' => date("Y-m-d H:i:s", time()));
         $add = $files_table->add($data);
     } else {
         $errorNo = $up->getErrorNo();
         if ($errorNo != 2) {
             echo $info = $up->getErrorMsg();
             exit;
         }
     }
     if ($add > 0) {
         $descrtption = $username . '上傳了關於BUG編號為:' . $report['bugno'] . '的附件';
         $log_data = array('pro_id' => $report['pid'], 'descrtption' => $descrtption);
         $Log->actLog($log_data);
         echo 1;
     } else {
         echo 0;
     }
 }
開發者ID:huangchuping,項目名稱:bug,代碼行數:54,代碼來源:ReportAction.class.php


注:本文中的UploadFile::getErrorNo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。