工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
查看: 2214|回复: 9

高薪聘请能够解决问题的高手(ASP上传问题)

[复制链接]
发表于 2008-6-15 13:04 | 显示全部楼层 |阅读模式
<style>
.font1{font-size:9pt;color:red}
</style>
<!--#include File="IncludeFile/Conn.asp"-->
<!--#include File="IncludeFile/upload.asp"-->
<%
dim Classname,DesignName,Designer,FileName
Classname=request("Classname")
'将文件上传到文件夹和数据库
dim myupload,uploadfile,path,name,PhotoID,JumpID
name=request.Cookies("name")
path="/photo/"+name+".bmp"
set myupload=new upload
set uploadfile=myupload.file("picture")
FileName=uploadfile.FileName
DesignName=myupload.form("text1")
Designer=myupload.form("text2")
PhotoID=uploadfile.saveAs(Server.mappath(path),Classname,DesignName,Designer)
set uploadfile=nothing
set myupload=nothing
GiveDllPath="E:\patentcookie\photo\"+name+".bmp"

  Set testDll = Server.CreateObject("AspMap.UseMap")
  testDll.done GiveDllPath,PhotoID,1

Session("GiveDllPath")=GiveDllPath
Session("PhotoID")=PhotoID
Session("Upload")="yes"
Session("FileName")=FileName
%>
<font class=font1>
<%
response.write("上传成功,本窗口将在5秒钟后自动关闭.........")
%>
</font>
<SCRIPT LANGUAGE=javascript>
<!--
setTimeout("window.opener=null;window.close();",2000);
//-->
</SCRIPT>

有信心的可到宿舍来帮忙!QQ:602489363
 楼主| 发表于 2008-6-15 13:05 | 显示全部楼层
在线等
回复

使用道具 举报

发表于 2008-6-15 13:06 | 显示全部楼层
高薪?聘请?
回复

使用道具 举报

 楼主| 发表于 2008-6-15 13:07 | 显示全部楼层
是啊!关键是解决问题没,其他都可以谈,时间紧
回复

使用道具 举报

 楼主| 发表于 2008-6-15 13:19 | 显示全部楼层
为什么一直显示正在上传,请等待!上传不上去
回复

使用道具 举报

发表于 2008-6-15 13:33 | 显示全部楼层
什么企业?

相信只是个小问题吧....描述清楚问题,有人懂的话自然会帮你的了...
回复

使用道具 举报

 楼主| 发表于 2008-6-15 14:45 | 显示全部楼层
upload.asp:
<%
dim Data

Class upload  

dim objForm,objFile,Version

Public function Form(strForm)
   strForm=lcase(strForm)
   if not objForm.exists(strForm) then
     Form=""
   else
     Form=objForm(strForm)
   end if
end function

Public function File(strFile)
   strFile=lcase(strFile)
   if not objFile.exists(strFile) then
     set File=new FileInfo
   else
     set File=objFile(strFile)
   end if
end function


Private Sub Class_Initialize
  dim RequestData,sStart,vbCrlf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,theFile
  dim iFileSize,sFilePath,sFileType,sFormValue,sFileName
  dim iFindStart,iFindEnd
  dim iFormStart,iFormEnd,sFormName
  Version="Version 2.0"
  set objForm=Server.CreateObject("Scripting.Dictionary")
  set objFile=Server.CreateObject("Scripting.Dictionary")
  if Request.TotalBytes<1 then Exit Sub
  set tStream = Server.CreateObject("adodb.stream")
  set Data = Server.CreateObject("adodb.stream")
  Data.Type = 1
  Data.Mode =3
  Data.Open
  Data.Write  Request.BinaryRead(Request.TotalBytes)
  Data.Position=0
  RequestData =Data.Read

  iFormStart = 1
  iFormEnd = LenB(RequestData)
  vbCrlf = chrB(13) & chrB(10)
  sStart = MidB(RequestData,1, InStrB(iFormStart,RequestData,vbCrlf)-1)
  iStart = LenB (sStart)
  iFormStart=iFormStart+iStart+1
  while (iFormStart + 10) < iFormEnd
        iInfoEnd = InStrB(iFormStart,RequestData,vbCrlf & vbCrlf)+3
        tStream.Type = 1
        tStream.Mode =3
        tStream.Open
        Data.Position = iFormStart
        Data.CopyTo tStream,iInfoEnd-iFormStart
        tStream.Position = 0
        tStream.Type = 2
        tStream.Charset ="gb2312"
        sInfo = tStream.ReadText
        tStream.Close
        '取得表单项目名称
        iFormStart = InStrB(iInfoEnd,RequestData,sStart)
        iFindStart = InStr(22,sInfo,"name=""",1)+6
        iFindEnd = InStr(iFindStart,sInfo,"""",1)
        sFormName = lcase(Mid (sinfo,iFindStart,iFindEnd-iFindStart))
        '如果是文件
        if InStr (45,sInfo,"filename=""",1) > 0 then
                set theFile=new FileInfo
                '取得文件名
                iFindStart = InStr(iFindEnd,sInfo,"filename=""",1)+10
                iFindEnd = InStr(iFindStart,sInfo,"""",1)
                sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
                theFile.FileName=getFileName(sFileName)
                theFile.FilePath=getFilePath(sFileName)
                '取得文件类型
                iFindStart = InStr(iFindEnd,sInfo,"Content-Type: ",1)+14
                iFindEnd = InStr(iFindStart,sInfo,vbCr)
                theFile.FileType =Mid (sinfo,iFindStart,iFindEnd-iFindStart)
                theFile.FileStart =iInfoEnd
                theFile.FileSize = iFormStart -iInfoEnd -3
                theFile.FormName=sFormName
                if not objFile.Exists(sFormName) then
                  objFile.add sFormName,theFile
                end if
        else
        '如果是表单项目
                tStream.Type =1
                tStream.Mode =3
                tStream.Open
                Data.Position = iInfoEnd
                Data.CopyTo tStream,iFormStart-iInfoEnd-3
                tStream.Position = 0
                tStream.Type = 2
                tStream.Charset ="gb2312"
                sFormValue = tStream.ReadText
                tStream.Close
                if objForm.Exists(sFormName) then
                  objForm(sFormName)=objForm(sFormName)&", "&sFormValue                  
                else
                  objForm.Add sFormName,sFormValue
                end if
        end if
        iFormStart=iFormStart+iStart+1
        wend
  RequestData=""
  set tStream =nothing
End Sub

Private Sub Class_Terminate  
if Request.TotalBytes>0 then
        objForm.RemoveAll
        objFile.RemoveAll
        set objForm=nothing
        set objFile=nothing
        Data.Close
        set Data=nothing
end if
End Sub
   

Private function GetFilePath(FullPath)
  If FullPath <> "" Then
   GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
  Else
   GetFilePath = ""
  End If
End  function

Private function GetFileName(FullPath)
  If FullPath <> "" Then
   GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
  Else
   GetFileName = ""
  End If
End  function
End Class

Class FileInfo
  dim FormName,FileName,FilePath,FileSize,FileType,FileStart
  Private Sub Class_Initialize
    FileName = ""
    FilePath = ""
    FileSize = 0
    FileStart= 0
    FormName = ""
    FileType = ""
  End Sub
  
Public function SaveAs(FullPath,SearchClass,DesignName,Designer)
    dim dr,ErrorChar,i,picture,picture2
    SaveAs=true
    if trim(fullpath)="" or FileStart=0 or FileName="" or right(fullpath,1)="/" then exit function
    set dr=CreateObject("Adodb.Stream")
    dr.Mode=3
    dr.Type=1
    dr.Open
    Data.position=FileStart
    picture=Data.Read(FileSize)
    Data.position=FileStart
    Data.copyto dr,FileSize
    dr.SaveToFile FullPath,2
    db_conn=request.Cookies("db_conn")
    sql="select * from "&SearchClass&""
    Rs.open sql,conn,1,3
    if Rs.RecordCount=0 then '当记录集中无记录时的加入方式
%>
<font class=font1>
<%
      response.write "记录集中没记录,用ID为零的方式加入新记录"
%>
</font>
<%
      Rs.close
      conn.execute("insert into "&SearchClass&"(ID) values('0')")
      sql="select * from "&SearchClass&" where ID='0'"
      Rs.open sql,conn,1,3
      Rs("名称")=DesignName
      Rs("发明人")=Designer
      set field=Rs.fields("图片1")
      field.appendchunk picture
      Rs.Update
    else '当记录集中有记录集时采取的加入方式
      Rs.MoveLast
      dim temp
      temp=Rs("ID")
      temp=temp+1
      Rs.addnew
      Rs("名称")=DesignName
      Rs("发明人")=Designer
      Rs("ID")=temp
      set field=Rs.fields("图片1")
      field.appendchunk picture
      Rs.Update
    end if
    SaveAS=Rs("ID")
    Rs.close
    set Rs=nothing
    set conn=nothing   
    dr.Close
    set dr=nothing
  end function
  End Class
%>
回复

使用道具 举报

 楼主| 发表于 2008-6-15 14:47 | 显示全部楼层
改了权限,增加了EVERYONE写入,还是报错:
错误类型:
ADODB.Stream (0x800A0BBC)
写入文件失败。
/patent/IncludeFile/upload.asp, 第 163 行


浏览器类型:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)

网页:
POST 545245 ??? /patent/Uploads.asp

POST Data:
错误 '80020009'
发生意外。

/iisHelp/common/500-100.asp,行 219
回复

使用道具 举报

 楼主| 发表于 2008-6-19 14:27 | 显示全部楼层
已解.
回复

使用道具 举报

发表于 2008-6-19 16:21 | 显示全部楼层
老了。

  Set testDll = Server.CreateObject("AspMap.UseMap")

这个不知是什么上传组件。记得以前写asp的时候都是用稻香居士的无组件上传~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2025-5-14 06:25

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表