<!--#include file="../../lib/base.asp"-->
<%
Dim qString
qString = Request.QueryString()
openJpeg "http://www.liantu.com/api.php?"&qString

function save_outfile(byval t0)
	on error resume next
	dim stm,http,filedata,filesize,filename
	filename="temp.png"
	set http=server.createobject(xmlhttp)
	with http
		.open "get",t0,false,"",""
		.send
		filedata=.responsebody
		filesize=eycms.getnum(round(eycms.lenb(filedata))/1024)
	end with
	set stm=server.createobject("adodb.stream")
	with stm
		.type=1
		.open
		.write filedata
		.savetofile server.mappath(filename), 2
		.cancel
	.close
	end with
	set stm=nothing
	if err then
		save_outfile=false
	else
		save_outfile=true
	end if
end function

function openJpeg(filename)
	If left(LCase(filename),7)="http://" Then 
		save_outfile filename
		filename="temp.png"
	End if
	dim stream
	set stream = Server.CreateObject("ADODB.Stream")
	stream.mode = 3 '1－读，2－写，3－读写
	stream.type = 1 '1－二进制，2－文本
	stream.Open
	stream.LoadFromFile server.mappath(FileName)
	openJpeg = stream.Read()
	stream.Close

	Response.ContentType = "image/jpeg"  
	Response.Buffer = True  
	Response.Clear  
	Response.BinaryWrite openJpeg  
	Response.Flush
end function
%>
