本文整理匯總了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'];
}
}