当前位置: 首页>>代码示例>>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;未经允许,请勿转载。