コード例 #1
0
ファイル: upload.php プロジェクト: a195474368/ejw
}
//普通用户
if (!$_G['manager']['id'] && $session) {
    Module::loader('passport', 'function');
    $hash = Passport::session_decode($session);
    if ($hash['id']) {
        $sid = 'member';
    }
}
//会话域
if (!$sid) {
    alert(1, '您当前不在登录状态(' . $sid . ')');
} elseif (empty($_FILES) === FALSE) {
    //连接数据库
    System::connect();
    $res = Attach::savefile(array('field' => 'imgFile', 'filetype' => 'image', 'account' => $sid, 'absolute' => TRUE));
    //关闭数据库
    System::connect();
    if ($res) {
        alert(0, NULL, $res);
    } else {
        alert(1, '文件上传出现错误(' . $sid . ')', $res);
    }
}
/*
	输出消息
	$err	0 无错 1 有错
	$msg	消息内容
	$url	附件地址
*/
function alert($err, $msg, $url = NULL)
コード例 #2
0
ファイル: serv.php プロジェクト: a195474368/ejw
 if (getgpc('watermark') == 'false') {
     $param['watermark'] = FALSE;
 }
 //是否远程存储
 if (getgpc('remote') == 'false') {
     $param['remote'] = FALSE;
 }
 //是否返回绝对地址
 if (getgpc('absolute') == 'true') {
     $param['absolute'] = TRUE;
 }
 //文件字段名
 if (getgpc('field')) {
     $param['field'] = getgpc('field');
 }
 $file = Attach::savefile($param);
 if ($model == 'flash') {
     echo '{ "file":"' . $file . '", "error":"' . Attach::$error . '" }';
 } else {
     //是否要求跨域
     $crossdomain = getgpc('crossdomain');
     header('Content-Type:text/html; charset=' . $_G['product']['charset']);
     /*
     if( $_G['setting']['global']['domain'] && strpos( $_SERVER['HTTP_REFERER'], $_G['setting']['global']['domain'] ) ){
     	header( 'Access-Control-Allow-Origin:'.$_SERVER['HTTP_REFERER'] );
     }
     */
     echo '<script type="text/javascript">';
     echo $crossdomain == 'true' ? System::cross_domain() : '';
     if ($file) {
         echo 'parent.Serv.Upload.Done( "' . $input . '", "' . $file . '","' . Attach::$detail['size'] . '", { "width" : "' . Attach::$detail['width'] . '", "height" : "' . Attach::$detail['height'] . '" });';