本文整理汇总了PHP中UploadFile::error方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadFile::error方法的具体用法?PHP UploadFile::error怎么用?PHP UploadFile::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadFile
的用法示例。
在下文中一共展示了UploadFile::error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* 添加/修改文章
*/
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);
}
}
示例2: array
<?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'];
}
}