日期:2010-09-09  浏览次数:20968 次

  首先,图片在页面中能查找选择。设计表单页面index.asp和上传选择页upload.asp,upload.asp在index.asp中以iframe包含。

  其次,所选图片应能上传到某文件夹。建立一文件夹uploadimg

  最后,传上去的图片应如何引用?很显然,采用UBB立即显示。upload.asp的指向对象upfile.asp具有写入UBB标签的功能。


无组件上传调试文件夹
    -- index.asp
    -- upload.asp
    -- upfile.asp
    -- uploadimg文件夹

  图片上传采用稻香老农的无组件上传。所以upload.inc文件必不可少。

  1,upload.inc

<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
dim upfile_5xSoft_Stream
Class upload_5xSoft 
dim Form,File,Version 
Private Sub Class_Initialize
        dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
        dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
        Version=""
        if Request.TotalBytes<1 then Exit Sub
        set Form=CreateObject("Scripting.Dictionary")
        set File=CreateObject("Scripting.Dictionary")
        set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
        upfile_5xSoft_Stream.mode=3
        upfile_5xSoft_Stream.type=1
        upfile_5xSoft_Stream.open
        upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)       
        vbEnter=Chr(13)&Chr(10)
        iDivLen=inString(1,vbEnter)+1
        strDiv=subString(1,iDivLen)
        iFormStart=iDivLen
        iFormEnd=inString(iformStart,strDiv)-1
        while iFormStart < iFormEnd
          iStart=inString(iFormStart,"name=""")
          iEnd=inString(iStart+6,"""")
          mFormName=subString(iStart+6,iEnd-iStart-6)
          iFileNameStart=inString(iEnd+1,"filename=""")
          if iFileNameStart>0 and iFileNameStart<iFormEnd then
           iFileNameEnd=inString(iFileNameStart+10,"""")
           mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
           iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
           iEnd=inString(iStart+4,vbEnter&strDiv)
           if iEnd>iStart then
            mFileSize=iEnd-iStart-4
           else
            mFileSize=0
           end if
           set theFile=new FileInfo
           theFile.FileName=getFileName(mFileName)
           theFile.FilePath=getFilePath(mFileName)