<!--#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>
<LINK href="style.css" type=text/css rel=stylesheet>
</head>
<body topmargin="20">
<!--#include FILE="uploadfile_inc.asp"--> 
<%
	set upload=new upload_5xsoft
	set file=upload.file("file1")
	if file.fileSize>0 then
		'自动生成文件名
		if file.fileSize>50*1024 then
			Response.Write("图片已经超出50K的上限，请压缩再传")
			response.write "<a href=uploadphoto.asp>返回"
		else
			filename=Request.Cookies("admin_person_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/person/"&filename)
				Set rs= Server.CreateObject("ADODB.RecordSet")
				sql="select pic from person where uname='"&Request.Cookies("admin_person_name")&"'"
				rs.open sql,conn,2,3
				rs("pic")=filename
				rs.update
				rs.close
				set rs=nothing
				response.write"<SCRIPT language=JavaScript>alert('照片上传成功，现在为您返回，请稍等');"
				response.write"this.location.href='uploadphoto.asp';</SCRIPT>"
		
			else
				response.write"<SCRIPT language=JavaScript>alert('文件格式不对，现在为您返回，请稍等');"
				response.write"this.location.href='uploadphoto.asp';</SCRIPT>"
			end if
			set file=nothing
		end if
	else
		response.write"<SCRIPT language=JavaScript>alert('文件内容不能为空，现在为您返回，请稍等');"
		response.write"this.location.href='uploadphoto.asp';</SCRIPT>"
	end if
	set upload=nothing
%>