关于无组建上传的问题

helei33 2002-04-26 02:18:24
我这里有一个无组建上传程序,可是当文件超过300k左右就速度特慢而且还经常超时(头疼),只能上传些小文件,那位兄台有关于无组建上传的程序,麻烦给小弟几段代码!或者告诉我写网址,谢了!!
...全文
38 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
julyclyde 2002-04-26
  • 打赏
  • 举报
回复
用C++直接做ISAPI类接收会如何?
ChinaOk 2002-04-26
  • 打赏
  • 举报
回复
无组件都不能传太大的文件。因为无组件通过asp来执行大量的运算。
你看代码也可以看到,一个字节一个字节的取。

所以要高效,肯定不能无组件。
不然你就用xml文件帮助上传试试
xml来显示我没用过,不知道效率如何。

—————————————————————————————————
┏━★━━◆━━★━┓
♂欢|◢CSDN◣|使♂        ▲自由保存帖子,浏览,关注检测
┃迎|◥论坛助手◤|用┃        ▲完善的CSDN客户端工具
┗━☆━━◇━━━☆┛        ▲自动添加签名.........
http://www.csdn.net/expert/topic/573/573604.xml
helei33 2002-04-26
  • 打赏
  • 举报
回复
稻香老农的无组件上传代码和我原来的差不多,他还是不能上传大一点的文件,困惑!!
shan__le 2002-04-26
  • 打赏
  • 举报
回复
你找那个稻香老农的一个无组件上传的代码,还不错,大概可以满足300K以上的要求,好像可以达到1.2M具体的忘记了,在www.aspsky.net的上面找.
jxwangzhigang 2002-04-26
  • 打赏
  • 举报
回复
<html>

<head>
<title>保存图片到数据库</title>
</head>

<body>
<b>

<p></b>你可以找个图片试试,保存完毕后会有提示</p>

<form METHOD="POST" ENCTYPE="multipart/form-data" ACTION="savetodb.asp">
<p>Email : <input NAME="email" VALUE="wangcq@sina.com" size="20"><br>
Picture : <input TYPE="file" NAME="blob"><br>
<input TYPE="submit" NAME="Enter"> </p>
</form>
</body>
</html>

savetodb.asp
----------------------------------
<%

Response.Buffer = TRUE
Response.Clear
byteCount = Request.TotalBytes

RequestBin = Request.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")

BuildUploadRequest RequestBin

email = UploadRequest.Item("email").Item("Value")

contentType = UploadRequest.Item("blob").Item("ContentType")
filepathname = UploadRequest.Item("blob").Item("FileName")
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
picture = UploadRequest.Item("blob").Item("Value")

'Response.ContentType = contentType
'Response.binaryWrite picture

set objCn = server.createobject("adodb.connection")
set objRst = server.createobject("adodb.recordset")
objCn.Open "upload"
objrst.Open "pic", objcn, 1,3,2
objrst.addnew
objrst.fields("filename")=filename
objrst.fields("type")="gif"

objrst.fields("what").appendchunk picture
objrst.update
response.write "<a href=showpic.asp?id=" & objrst("id") & ">第" & objrst("id") & "个图片。</a>"
objrst.close

objCn.close
set objrst=nothing
set objcn = nothing
%>
<!--#include file="upload.asp"-->

showpic.asp
----------------------------------------
<%
set objCn = server.createobject("adodb.connection")
set objRst = server.createobject("adodb.recordset")
objCn.Open "upload"
objrst.Open "select what from pic where id=" & request("id"), objcn

if not objrst.eof then
response.binarywrite objrst("what")
end if

objrst.close
objCn.close
set objrst=nothing
set objcn = nothing
%>


upload.asp
-------------------------------------------
<%
Sub BuildUploadRequest(RequestBin)
'Get the boundary
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
'Get all data inside the boundaries
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
'Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
'Get an object name
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,RequestBin,boundary)
'Test if object is of file type
If PosFile<>0 AND (PosFile<PosBound) Then
'Get Filename, content-type and content of file
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
'Add content-type to dictionary object
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
'Get content of object
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
'Get content of object
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
'Add content to dictionary object
UploadControl.Add "Value" , Value
'Add dictionary object to main dictionary
UploadRequest.Add name, UploadControl
'Loop to next object
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop

End Sub

'String to byte string conversion
Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function

'Byte string to string conversion
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function
%>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧