<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<!--#include file="../inc/setup.asp"-->
<!--#include file="../inc/sql.asp"-->
<%
	end if
	Response.Buffer=True
%>
<html>
<head>
<title>图片上传</title>
</head>
<body topmargin="20">
<!--#include FILE="../person/uploadfile_inc.asp"--> 
<%
	set upload=new upload_5xsoft
	set file=upload.file("file1")
	if file.fileSize>0 then
    '自动生成文件名
	if file.fileSize>500*1024 then
		Response.Write("图片已经超出50K的上限，请压缩再传")
		response.write "<a href=pwd.asp>返回"
	else
    filename=Request.Cookies("admin_train_name")
    filename=replace(filename,"-","")
    filename=replace(filename,":","")
    filename=replace(filename," ","")
    filename=filename+"."
    filenameend=file.filename
    filenameend=split(filenameend,".")
    if filenameend(1)="gif" or filenameend(1)="jpg" or filenameend(1)="jpeg" or filenameend(1)="bmp"then
        filename=filename&filenameend(1)
        file.saveAs Server.mappath("../upimages/train/"&filename)
	Set rs= Server.CreateObject("ADODB.RecordSet")
	sql="select logo from train where tname='"&Request.Cookies("admin_train_name")&"'"
	rs.open sql,conn,2,3
	rs("logo")=filename
	rs.update
	rs.close
	set rs=nothing
	response.write"<SCRIPT language=JavaScript>alert('图片上传成功，现在为您返回，请稍等');"
	response.write"this.location.href='train_main_html.asp';</SCRIPT>"
%>
<%
    else
		response.write"<SCRIPT language=JavaScript>alert('文件格式不对，现在为您返回，请稍等');"
		response.write"this.location.href='pwd.asp';</SCRIPT>"
    end if
    set file=nothing
	end if
	else
		response.write"<SCRIPT language=JavaScript>alert('文件内容不能为空，现在为您返回，请稍等');"
		response.write"this.location.href='pwd.asp';</SCRIPT>"
	end if
	set upload=nothing
	response.write "<br>"
%>