本文整理汇总了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;
//.........这里部分代码省略.........
示例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;
}
}