首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

图片上载

2012-09-15 
图片下载怎么实现图片下载(代码)?急[解决办法]另存为:Cls_DownFile.AspVB code%Class MainDownFilePrivat

图片下载
怎么实现图片下载(代码)?急

[解决办法]
另存为:Cls_DownFile.Asp

VB code
<%Class MainDownFile    Private mSourceFilePath    Private mNewFileName    '=====================================================    ' 设置源文件路径    '=====================================================    Public Property Let SetSourceFilePath(ByVal NewVal)        mSourceFilePath = Server.MapPath(NewVal)    End Property    '=====================================================    ' 设置新文件名    '=====================================================    Public Property Let SetNewFileName(ByVal NewVal)        mNewFileName = NewVal    End Property    Private Sub Class_Initialize()    End Sub    Public Sub ShowDownFile()        Dim AdoStr        Set AdoStr = CreateObject("Adodb.Stream")        AdoStr.Mode = 3        AdoStr.Type = 1        AdoStr.Open        AdoStr.LoadFromFile(mSourceFilePath)        If Err.Number > 0 Then            Response.Status = "404"        Else            Response.ContentType = "application/octet-stream"            Response.AddHeader "Content-Disposition:", "attachment; filename=" & RemoteNewFile()            Range = Mid(Request.ServerVariables("http_range"), 7)            If Range = "" Then                Response.BinaryWrite(AdoStr.Read)            Else                AdoStr.position = CLng(Split(Range, "-")(0))                Response.BinaryWrite(AdoStr.Read)            End If        End If        Set AdoStr = Nothing    End Sub    '========================================================    '函数名:GetExt    '作  用:获取文件后缀    '参  数:FileName为文件名    '返回值:文件后缀,不包含点,如:index.html = html    '========================================================    Private Function GetExt(FileName)        GetExt = Mid(FileName, InstrRev(FileName, ".") + 1)    End Function    Private Function RemoteNewFile()        Dim mNewFile        mNewFile = GetExt(mSourceFilePath)        RemoteNewFile = mNewFileName & "." & mNewFile    End FunctionEnd Class%> 

热点排行