<!--#include file=conn.asp-->
<!--#include file=config.asp-->
<%
 '=========================================================
' File: showpics.asp
' Version:3.0
' Date: 2005-9-22
' Script Written by xmrxw
'=========================================================
' Copyright (C) 2004,2005 Xmrxw.Com All rights reserved.
' Web: http://www.xmrxw.com,http://www.xmzxw.com
' Email: info@mssky.com,super@mssky.com
' QQ£º10689579¡¡Msn£ºzdlmicr@hotmail.com
'=========================================================
dim picurl,rs,sql,Fid
Fid=trim(request("Fid"))
Fid=Clng(Fid)
set rs=server.createobject("adodb.recordset")
	sql="select Filename from [Ms_Upphoto] where Fid="&Fid&""
	rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
picurl=rs("Filename")
end if
rs.close
   set rs=nothing
   conn.close
   set conn=nothing
   If Request.ServerVariables("HTTP_REFERER")="" Or InStr(Request.ServerVariables("HTTP_REFERER"),Request.ServerVariables("SERVER_NAME"))=0 Or Fid="" Then
	Call downloadFile(Server.MapPath(Weblogo))
Else
		If SaveUpFilesPath="" Or SaveUpFilesPath="0" Then SaveUpFilesPath="UploadFile/"
		If right(SaveUpFilesPath,1)<>"/" Then SaveUpFilesPath=SaveUpFilesPath&"/"
		Call downloadFile(Server.MapPath(SaveUpFilesPath&picurl))
End If
Sub downloadFile(strFile)
	On error resume next
	Server.ScriptTimeOut=999999
	Dim S,fso,f,intFilelength,strFilename
	strFilename = strFile
	Response.Clear
	Set s = Server.CreateObject("ADODB.Stream") 
	s.Open
	s.Type = 1 
	Set fso = Server.CreateObject("Scripting.FileSystemObject") 
	If Not fso.FileExists(strFilename) Then
		Call downloadFile(Server.MapPath(Weblogo))
		Exit Sub		
	End If
	Set f = fso.GetFile(strFilename)
	intFilelength = f.size
	s.LoadFromFile(strFilename)
	If err Then
	 	Response.Write("<h1>´íÎó: </h1>" & err.Description & "<p>")
		Response.End 
	End If
	Set fso=Nothing
	Dim Data
	Data=s.Read
	s.Close
	Set s=Nothing
	If Response.IsClientConnected Then
		If Not (InStr(LCase(f.name),".gif")>0 Or InStr(LCase(f.name),".jpg")>0 Or InStr(LCase(f.name),".jpeg")>0 Or InStr(LCase(f.name),".bmp")>0 )Then 
			Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name 
		End If
		Response.AddHeader "Content-Length", intFilelength 
 		Response.CharSet = "UTF-8" 
		Response.ContentType = "application/octet-stream"
		Response.BinaryWrite Data
		Response.Flush
	End If
End Sub%>