<?php
defined('IN_HS') or exit('Access Denied');
echo "<body bgcolor=#FFF>";
@set_time_limit(600);
$channelid = intval($channelid);
if(!$channelid) exit;


if($dosubmit)
{
	if(isset($CHA))
	{
		@extract($CHA);
	}
	elseif(isset($MOD))
	{
		@extract($MOD);
	}
	else
	{
		@extract($HS);
	}
	require_once HS_ROOT.'/include/upload.class.php';

	$filepath = $HS['uploaddir'].'/'.$CHA['channeldir'].'/'.$MOD['upload_dir'].'/'.date('Ym').'/';
	is_dir(HS_ROOT.'/'.$filepath) or dir_create(HS_ROOT.'/'.$filepath);
		$key = array_keys($_FILES);
		$k = $key[0];
		$filearray = array('file'=>$_FILES[$k]['tmp_name'],'name'=>$_FILES[$k]['name'],'size'=>$_FILES[$k]['size'],'type'=>$_FILES[$k]['type'],'error'=>$_FILES[$k]['error']);
		$filename = (isset($rename) && $rename == 1) ? '' : $_FILES[$k]['name'];
		$upload = new upload($filearray, $filename, $filepath, $CHA['uploadfiletype'], 1, $CHA['maxfilesize']);
		if($upload->up())
		{
			$saveto = str_replace($HS['uploaddir'].'/'.$CHA['channeldir'].'/'.$MOD['upload_dir'].'/', '', $upload->saveto);
			echo '<script>parent.document.getElementById("pictureurls").value = "'.$saveto.'";</script>';
			msg('上传成功');
		}
		else
		{
			msg('上传失败');
		}
}
else
{
	include admintpl('upload');
}
?>