<%
Dim Stream,FilePath,FileExt,ContentType
FilePath = Request.QueryString("path")
FileExt = Mid( FilePath, InstrRev(FilePath,".")+1 )
ContentType = ""
if UCase( FileExt ) = "JPEG" then
ContentType = "image/jpeg"
end if
if UCase( FileExt ) = "JPG" then
ContentType = "image/jpeg"
end if
if UCase( FileExt ) = "GIF" then
ContentType = "image/gif"
end if
if UCase( FileExt ) = "PNG" then
ContentType = "image/png"
end if
Set Stream = Server.CreateObject("ADODB.Stream")
Call Stream.Open()
Stream.Type = adTypeBinary
on error resume next
if Instr( FilePath, "\" ) <> 0 then
Call Stream.LoadFromFile( FilePath )
if Err.Number <> 0 then
ContentType = ""
end if
else
Call Stream.LoadFromFile( Server.MapPath(FilePath) )
if Err.Number <> 0 then
ContentType = ""
end if
end if
on error goto 0
if ContentType = "" then
Response.ContentType = "image/png"
FilePath = Server.MapPath("err.png")
Call Stream.LoadFromFile( FilePath )
else
Response.ContentType = ContentType
end if
Call Response.BinaryWrite( Stream.Read )
Call Stream.Close()
Set Stream = Nothing
%>
<%
' **********************************************************' ダウンロード' **********************************************************
Function GetData( )
Dim Http,Stream
Dim Target,TargetFile
' リモート Web 上のターゲットアドレス
Target = MyData("In1Target")
' ローカル Web 上のターゲットアドレス
TargetFile = "file/" & Mid( Target, InstrRev(Target,"/")+1 )
' ダウンロード用のオブジェクト
Set Http = Server.CreateObject( "MSXML2.XMLHTTP" )
on error resume next
Call Http.Open("GET", Target, FALSE )
if Err.Number <> 0 then
Call OutCr( "<PRE>" )
Call OutCr( "アドレス:" & Target )
Call OutCr( Err.Description )
Call OutCr( "</PRE>" )
Set Fs = Stream
Set Http = Nothing
Exit Function
end if
on error goto 0
Call Http.Send()
' ファイル化用のオブジェクト
Set Stream = Server.CreateObject("ADODB.Stream")
Call Stream.Open()
Stream.Type = adTypeBinary
Call Stream.Write( Http.responseBody )
Call Stream.SaveToFile( _
Server.MapPath(TargetFile), _
adSaveCreateOverWrite _
)
Call Stream.Close()
Set Stream = Nothing
Set Http = Nothing
OutData = "<IMG src=""file.asp?path=" OutData = OutData & Server.URLEncode(TargetFile) & """>"
End Function
' **********************************************************' VIEW の編集' **********************************************************
Function EditDataHead( )
End Function
' **********************************************************' VIEW2 の編集' **********************************************************
Function EditDataBody( )
End Function
%>