if (!defined('BLOG')) { exit('Access Denied'); } $do = !empty($_GET['do']) ? $_GET['do'] : ''; $doarr = array('article-new'); if (!in_array($do, $doarr)) { jsonOutput(2, '不允许的操作'); } $upload = new class_upload(); switch ($do) { case 'article-new': if (!$_B['uid']) { jsonOutput(2, 'login'); } $upload->init($_FILES['file'], 'article', 'data/attachment'); $file =& $upload->file; if (!$file['isimage']) { jsonOutput(2, '请上传图片附件 0027'); } if ($file['size'] > 2097152) { //2M jsonOutput(2, '请上传小余 2M 的图片 0032'); } $upload->save($file['tmp_name'], $file['target']); $errorcode = $upload->error(); if ($errorcode < 0) { $data = $upload->errormsg(); @unlink($file['target']); jsonOutput(2, $data); }