<%
'商易仿淘宝4.0(多用户)
'ACCESS版演示网站：http://www.ftaobao.com(商易仿淘宝商城)
'SQL版演示网站：http://sql.ftaobao.com
'电话：0571-56907100
'QQ：1147100
%>
<%'//定义上传文件大小，单位KB
sc_dx=75%>
<!--#include file="../include/conn.asp"-->
<!--#include file="fso.asp"-->
<!--#include file="../include/money.asp"-->
<html>
<head>
<link href="../include/css.css" rel="stylesheet" type="text/css">
</head>
<%hy "../user/login.asp"

if request("chuan") = "yes" then
server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))	
if not mid(server_v1,8,len(server_v2))=server_v2 then
Response.Write "<script language=JavaScript>{window.alert('错误：拒绝从非本服务器页面提交信息!');window.history.go(-1);}</script>"
response.end
end if
set c=new clsUp
c.AllowExt="gif;jpg;" '限制文件格式
c.SetFileSize(sc_dx*1024)	 '最大文件大小
randomize
ranNum=int(900*rnd)+100 
wj=trim(year(date()))&right("0"&trim(month(date)),2)&right("0"&trim(day(date)),2)&right("0"&trim(hour(time())),2)&right("0"&trim(minute(time())),2)&right("0"&trim(second(time())),2)&ranNum
wz="../user/images/banner/"&wj
FSPath=server.MapPath(wz)
fn=c.AutoSave("file",FSPath&"/")	
if c.iserr then 
Response.Write c.errmessage
else
tp=fn
dx=c.Filesize
response.write "上传成功 [<a href=# onclick=history.go(-1)>重新上传</a>]"
end if
set c=nothing 
response.write "<script>parent.myform.banner.src='../user/images/banner/"&tp&"'</script>"
'将原有上传图片删除
del_tp=conn.execute("select banner from shop where huiyuan='"&replace(Request.Cookies(Rikee)("huiyuan"),"'","")&"'")(0)
if del_tp<>"" then
wj="../user/images/banner/"&del_tp
del_wj_myfso wj
conn.execute("Delete * from shangchuan where name='"&replace(Request.Cookies(Rikee)("huiyuan"),"'","")&"' and tp='../user/images/banner/"&del_tp&"'")
end if
'将上传图片记录入数据库以备审核
if Request.ServerVariables("HTTP_X_FORWARDED_FOR") = ""  then
ip=Request.ServerVariables("REMOTE_ADDR")
else
ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
end if
conn.execute("Insert into shangchuan(tp,dx,name,lx,ip)values('../user/images/banner/"&tp&"',"&dx&",'"&replace(Request.Cookies(Rikee)("huiyuan"),"'","")&"',0,'"&ip&"')")
conn.execute("Update shop set banner = '"&tp&"' where  huiyuan='"&replace(Request.Cookies(Rikee)("huiyuan"),"'","")&"'")

'结束上传
response.write "&nbsp;&nbsp;&nbsp;成功上传！"
response.end
end if%>
<script>
var img=null;
function sc(){ 
//判断是否图片  inp为文本框id
form.btn.disabled=true;
if(img)img.removeNode(true);
img=document.createElement("img"); //创建img对象
img.style.position="absolute";
img.style.visibility="hidden";
img.attachEvent("onreadystatechange",orsc);
img.attachEvent("onerror",oe);
document.body.insertAdjacentElement("beforeend",img);
img.src=form.inp.value;}
function oe(){
//判断浏览器及版本
var ua=navigator.userAgent;
var ie=false;
if(navigator.appName=="Microsoft Internet Explorer"){
ie=true;}
if(!ie){
form.file.outerHTML=form.file.outerHTML.replace(/value=\w/g,'');
alert("建议您使用IE6。0以上的浏览器,在非IE浏览器中上传功能不能正常使用。");
return;}
var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))));
if(IEversion< 6.0){
form.file.outerHTML=form.file.outerHTML.replace(/value=\w/g,'');
alert("系统检测到您的浏览器的版本比较低,建议您使用IE6。0以上的浏览器,否则上传功能不能正常使用。\n您可以http://www.microsoft.com/china/免费获得IE的最新版本!");
return;}
//不是图片显示错误信息
alert("对不起，只能上传图片文件！");
form.file.outerHTML=form.file.outerHTML.replace(/value=\w/g,'');}
function orsc(){ 
//取得图片信息
var t
if(img.readyState!="complete")return false;
t=img.fileSize
form.img_s.value=t  //这是filesize
if (t><%=sc_dx*1024%>) {			
alert("对不起,上传图片不能超过指定大小<%=sc_dx%>kb！");
form.file.outerHTML=form.file.outerHTML.replace(/value=\w/g,'');
return false;}
form.btn.disabled=false;}
</script>
<form name="form" method="post" action="?chuan=yes" enctype="multipart/form-data" >
  <input name="file" type="file" class="wenbenkuang" size="40" id="inp" onChange="sc()">
  <input name="Submit" type="submit" class="wenbenkuang" value="上 传" id=btn disabled><input name="img_s" type="hidden" id="img_s">
</form></body></html>
