标题:ASP大虾,帮我看看,文件上传问题。等
取消只看楼主
ysdxhf
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2009-10-23
 问题点数:0 回复次数:0 
ASP大虾,帮我看看,文件上传问题。等
我现在用的这个ASP系统,能够上传 DOC\JIG\ZIP\等几种文件,就是不能上传EXCEL的文件,我怎么修改 才能上传XLS文件呢?谢谢帮助!

Private Sub Class_Initialize
    dim myupsize
        p_Error       = -1
        if GroupInfo(2)<>"" and GroupInfo(2)>0 Then
        myupsize=clng(GroupInfo(2))
        else
        myupsize=0
        end if
        p_MaxSize  = myupsize*1024  '单文件最大5M(字节)
       p_FileType = replace(GroupInfo(1),"|","/")     '允许上传rar/zip格式文件
        p_SavePath = "UploadFile/" '在当前目录保存文件,这里是相对路径,如:“UpLoadFile/”
        p_AutoSave = 0
        strDate       = replace(cstr(Date()),"-","")
        lngTime       = clng(timer()*1000)
        Set binForm = Server.CreateObject("ADODB.Stream")
        Set binItem = Server.CreateObject("ADODB.Stream")
        Set objForm = Server.CreateObject("Scripting.Dictionary")
         = 1
    End Sub

    Private Sub Class_Terminate
        objForm.RemoveAll
        Set objForm = nothing
        Set binItem = nothing
        binForm.Close()
        Set binForm = nothing
    End Sub

    Public Sub Open()
        if p_Error=-1 then
            p_Error=0
        else
            Exit Sub
        end if
        Dim lngRequestSize,binRequestData,strFormItem,strFileItem
        Const strSplit="'"">"
        lngRequestSize=Request.TotalBytes
        if lngRequestSize<1 then
            p_Error=3 '文件太小或没有选择文件
            Exit Sub
        end if
        binRequestData=Request.BinaryRead(lngRequestSize)
        binForm.Type = 1
        binForm.Open
        binForm.Write binRequestData

        Dim bCrLf,strSeparator,intSeparator
        bCrLf=ChrB(13)&ChrB(10)

        intSeparator=InstrB(1,binRequestData,bCrLf)-1
        strSeparator=LeftB(binRequestData,intSeparator)

        Dim p_start,p_end,strItem,strInam,intTemp,strTemp
        Dim strFtyp,strFnam,strFext,lngFsiz
        p_start=intSeparator+2
        Do
            p_end  =InStrB(p_start,binRequestData,bCrLf&bCrLf)+3
            binItem.Type=1
            binItem.Open
            binForm.Position=p_start
            binForm.CopyTo binItem,p_end-p_start
            binItem.Position=0
            binItem.Type=2
            binItem.Charset="gb2312"
            strItem=binItem.ReadText
            binItem.Close()

            p_start=p_end
            p_end  =InStrB(p_start,binRequestData,strSeparator)-1
            binItem.Type=1
            binItem.Open
            binForm.Position=p_start
            lngFsiz=p_end-p_start-2
            binForm.CopyTo binItem,lngFsiz

            intTemp=Instr(39,strItem,"""")
            strInam=Mid(strItem,39,intTemp-39)

            if Instr(intTemp,strItem,"filename=""")<>0 then
            if not objForm.Exists(strInam&"_From") then
                strFileItem=strFileItem&strSplit&strInam
                if binItem.Size<>0 then
                    intTemp=intTemp+13
                    strFtyp=Mid(strItem,Instr(intTemp,strItem,"Content-Type: ")+14)
                    strTemp=Mid(strItem,intTemp,Instr(intTemp,strItem,"""")-intTemp)
                    intTemp=InstrRev(strTemp,"\")
                    strFnam=Mid(strTemp,intTemp+1)
                    objForm.Add strInam&"_Type",strFtyp
                    objForm.Add strInam&"_Name",strFnam
                    objForm.Add strInam&"_Path",Left(strTemp,intTemp)
                    objForm.Add strInam&"_Size",lngFsiz
                    if Instr(intTemp,strTemp,".")<>0 then
                        strFext=Mid(strTemp,InstrRev(strTemp,".")+1)
                    else
                        strFext=""
                    end if
                    if left(strFtyp,6)="image/" then
                        binItem.Position=0
                        binItem.Type=1
                        strTemp=binItem.read(10)
                        if strcomp(strTemp,chrb(255) & chrb(216) & chrb(255) & chrb(224) & chrb(0) & chrb(16) & chrb(74) & chrb(70) & chrb(73) & chrb(70),0)=0 then
                            if Lcase(strFext)<>"jpg" then strFext="jpg"
                            binItem.Position=3
                            do while not binItem.EOS
                                do
                                    intTemp = ascb(binItem.Read(1))
                                loop while intTemp = 255 and not binItem.EOS
                                if intTemp < 192 or intTemp > 195 then
                                    binItem.read(Bin2Val(binItem.Read(2))-2)
                                else
                                    Exit do
                                end if
                                do
                                    intTemp = ascb(binItem.Read(1))
                                loop while intTemp < 255 and not binItem.EOS
                            loop
                            binItem.Read(3)
                            objForm.Add strInam&"_Height",Bin2Val(binItem.Read(2))
                            objForm.Add strInam&"_Width",Bin2Val(binItem.Read(2))
                        elseif strcomp(leftB(strTemp,8),chrb(137) & chrb(80) & chrb(78) & chrb(71) & chrb(13) & chrb(10) & chrb(26) & chrb(10),0)=0 then
                            if Lcase(strFext)<>"png" then strFext="png"
                            binItem.Position=18
                            objForm.Add strInam&"_Width",Bin2Val(binItem.Read(2))
                            binItem.Read(2)
                            objForm.Add strInam&"_Height",Bin2Val(binItem.Read(2))
                        elseif strcomp(leftB(strTemp,6),chrb(71) & chrb(73) & chrb(70) & chrb(56) & chrb(57) & chrb(97),0)=0 or strcomp(leftB(strTemp,6),chrb(71) & chrb(73) & chrb(70) & chrb(56) & chrb(55) & chrb(97),0)=0 then
                            if Lcase(strFext)<>"gif" then strFext="gif"
                            binItem.Position=6
                            objForm.Add strInam&"_Width",BinVal2(binItem.Read(2))
                            objForm.Add strInam&"_Height",BinVal2(binItem.Read(2))
                        elseif strcomp(leftB(strTemp,2),chrb(66) & chrb(77),0)=0 then
                            if Lcase(strFext)<>"bmp" then strFext="bmp"
                            binItem.Position=18
                            objForm.Add strInam&"_Width",BinVal2(binItem.Read(4))
                            objForm.Add strInam&"_Height",BinVal2(binItem.Read(4))
                        end if
                    end if
                    objForm.Add strInam&"_Ext",strFext
                    objForm.Add strInam&"_From",p_start
                    intTemp=GetFerr(lngFsiz,strFext)
                    if p_AutoSave<>2 then
                        objForm.Add strInam&"_Err",intTemp
                        if intTemp=0 then
                            if p_AutoSave=0 then
                                strFnam=GetTimeStr()
                                if strFext<>"" then strFnam=strFnam&"."&strFext
                            end if
                            binItem.SaveToFile Server.MapPath(p_SavePath&strFnam),2
                            objForm.Add strInam,strFnam
                        end if
                    end if
                else
                    objForm.Add strInam&"_Err",-1
                end if
            end if
            else

[ 本帖最后由 ysdxhf 于 2009-10-23 19:22 编辑 ]
搜索更多相关主题的帖子: 文件 ASP 
2009-10-23 19:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-289652-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.193181 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved