关于上传 下载的问题

zcm123 2004-08-02 11:55:14
我最近要编一个用于asp上的组建

实现功能如题。但是呢 我不知如何下手编(根本就不懂,怎么下手阿!)

各位大侠有原码 相关文档 的能否提供给在下呢?

必有重谢
...全文
146 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
liu9965012 2004-08-04
  • 打赏
  • 举报
回复
那位大哥能发份给我吗?谢谢
ZYL1018@163.com
online 2004-08-02
  • 打赏
  • 举报
回复

看来我也应该贴代码
zcm123 2004-08-02
  • 打赏
  • 举报
回复
谢谢各位版主 尤其是web版的
下面结贴
Jaron 2004-08-02
  • 打赏
  • 举报
回复
Public Function GetTheValue(nm As String) As String
'******************************参数说明*****************************
'* *
'* nm: 要取得值的 Form 元素名 *
'* *
'*******************************************************************

'------------------定义局部变量----------------------
Dim s As Long
Dim e As Long
Dim i As Long

Dim strTmp As String
Dim binTmp() As Byte
'-----------------------------------------------------------

'-----------------寻找数据的起始位置和结束位置-----------------
s = FindTheName(nm)
If s = -1 Then
GetTheValue = ""
Exit Function
End If
s = s + 5
e = FindTheDjf(s) - 3
'-----------------------------------------------------------

'----------------处理输入的数据为空的情况------------------
If e - s < 0 Then
GetTheValue = ""
Exit Function
End If
'-----------------------------------------------------------

'-----------------得到数据值------------------------
ReDim binTmp(e - s)
For i = s To e
binTmp(i - s) = binArray(i)
Next
strTmp = StrConv(binTmp, 64)
GetTheValue = strTmp
'-----------------------------------------------------------
End Function

Public Function SaveTheFile(strTag As String, strPath As String) As String

'******************************参数说明*****************************
'* *
'* strTag: HTML FORM中要上载的文件类型INPUT标签名 *
'* strPath: 目标路径名, 末尾不带"\"。如:"c:\images\upload" *
'* 返回值: 成功——文件名,失败—— "" *
'* *
'*******************************************************************

'------------------定义局部变量----------------------
Dim s As Long '起始位置
Dim e As Long '结束位置
Dim i As Long

Dim fileNo As Integer

Dim strFileName As String
Dim strTmp As String
Dim binTmp() As Byte
Dim newfile As String
'-----------------------------------------------------------

'---------得到文件名的起始位置---------------------------
s = FindTheName(strTag)
If s = -1 Then
SaveTheFile = ""
Exit Function
End If
s = s + 13
'-----------------------------------------------------------

'----------得到文件名的结束位置---------------------------
i = s
Do While 1
If binArray(i) = 34 Then
Exit Do
End If
i = i + 1
Loop
e = i - 1
'--------------------------------------------------------

'---------------处理客户端没有上载文件的情况---------------
If e - s < 0 Then
SaveTheFile = ""
Exit Function
End If
'-----------------------------------------------------------

'-------------------得到不带源路径的文件名-------------------
For i = e To s Step -1
If Chr(binArray(i - 1)) = "\" Then
s = i
Exit For
End If
Next
ReDim binTmp(e - s)
For i = s To e
binTmp(i - s) = binArray(i)
Next
strTmp = StrConv(binTmp, 64)
newfile = Year(Now()) & Month(Now()) & Day(Now()) & "_" & Replace(Time(), ":", "") & "." & Right(strTmp, 3)
strTmp = newfile
strFileName = strTmp
'-------------------------------------------------------------

'-----------------建立目标文件名-------------------------
strTmp = strPath & "\" & strTmp
'-------------------------------------------------------------

'-----------------寻找文件数据的起始位置------------------
i = e
Do While 1
If binArray(i - 4) = 13 And binArray(i - 3) = 10 And binArray(i - 2) = 13 And binArray(i - 1) = 10 Then
s = i
Exit Do
End If
i = i + 1
Loop
'-------------------------------------------------------------

'-----------------寻找文件数据的结束位置------------------
e = FindTheDjf(s) - 3
'-------------------------------------------------------------

'----------------------把文件数据存盘---------------------
fileNo = FreeFile() '为了防止存在同名文件,就先打开一个同名文件,
Open strTmp For Binary Access Write As #fileNo '然后再删除它
Put #fileNo, , "temp"
Close #fileNo
Kill strTmp

fileNo = FreeFile()
Open strTmp For Binary Access Write As #fileNo

If e - s >= 0 Then '如果 e-s<0 , 则是一个空文件
ReDim binTmp(e - s)
For i = s To e
binTmp(i - s) = binArray(i)
Next
Put #fileNo, , binTmp
End If

Close #fileNo
'-------------------------------------------------------------

SaveTheFile = strFileName '成功,返回文件名
End Function



Jaron 2004-08-02
  • 打赏
  • 举报
回复
偶这里有源代码:

Option Explicit

'------------------- 声明ASP对象---------------------
Private MyScriptingContext As ScriptingContext
Private MyRequest As Request
'---------------------------------------------------

'------------------定义全局变量----------------------
Private binArray() As Byte '---全部数据的数组
Private binDjf() As Byte '---定界符数组

Private intDjfLen As Integer '---定界符数组的长度
Private lngArrayLen As Long '---全部数据数组的长度
'---------------------------------------------------

Public Sub OnStartPage(PassedScriptingContext As ScriptingContext)

'------------------定义局部变量----------------------
Dim varByteCount
Dim i
'---------------------------------------------------

'------------------建立ASP对象-----------------------
Set MyScriptingContext = PassedScriptingContext
Set MyRequest = MyScriptingContext.Request
'---------------------------------------------------

'------------------读取客户端传来的全部数据-----------
varByteCount = MyRequest.TotalBytes
lngArrayLen = varByteCount - 1
ReDim binArray(varByteCount - 1)
binArray = MyRequest.BinaryRead(varByteCount)
'---------------------------------------------------

'--------------------获取定界符---------------------
intDjfLen = 0
Do Until binArray(intDjfLen + 1) = 13
intDjfLen = intDjfLen + 1
Loop
ReDim binDjf(intDjfLen)
For i = 0 To intDjfLen
binDjf(i) = binArray(i)
Next
'---------------------------------------------------
End Sub
Private Function FindTheDjf(lngStart As Long) As Long

'******************************参数说明
'* *
'* lngStart: 寻找的起始位置 *
'* 返回值: 成功—— 找到时的地址,失败—— -1 *
'* *
'*******************************************************************

'------------------定义局部变量----------------------
Dim i As Integer
Dim s As Long
Dim DjfOk As Integer
'---------------------------------------------------

'-----------------获取定界符的起始位置--------------------
s = lngStart
Do While 1
DjfOk = 1
For i = 0 To intDjfLen
If binDjf(i) <> binArray(s + i) Then
DjfOk = 0
Exit For
End If
Next
If DjfOk = 1 Then
FindTheDjf = s
Exit Do
Else
s = s + 1
If s >= lngArrayLen - intDjfLen Then
FindTheDjf = -1
Exit Do
End If
End If
Loop
'--------------------------------------------------------------
End Function


Private Function FindTheName(nm As String) As Long
'******************************参数说明*****************************
'* *
'* nm: 要寻找的 Form 元素名 *
'* 返回值: 成功—— 找到时的地址,失败—— -1 *
'* *
'*******************************************************************

'------------------定义局部变量----------------------
Dim s As Long
Dim e As Long
Dim i As Long

Dim binTmp() As Byte
Dim strName As String
'---------------------------------------------------

'------------------寻找要取得值的Form 元素名------------------------
s = 0
Do While 1
s = FindTheDjf(s)
If s <> -1 Then
s = s + intDjfLen + 41
e = s
Do While binArray(e + 1) <> 34
e = e + 1
Loop
ReDim binTmp(e - s)
For i = s To e
binTmp(i - s) = binArray(i)
Next
strName = StrConv(binTmp, 64)
If StrComp(nm, strName) = 0 Then
FindTheName = e + 1
Exit Do
End If
Else
FindTheName = -1
Exit Do
End If
Loop
'--------------------------------------------------------------
End Function
online 2004-08-02
  • 打赏
  • 举报
回复
发了
zcm123 2004-08-02
  • 打赏
  • 举报
回复
如何写成vb编的组件呢?
online 2004-08-02
  • 打赏
  • 举报
回复
我这里有aspcnupload的vb源代码
需要的话。留下email
zcm123 2004-08-02
  • 打赏
  • 举报
回复
zcm821214@yahoo.com.cn
online 2004-08-02
  • 打赏
  • 举报
回复
化境ASP无组件上传程序
http://www.chinaz.com/download/s/2178.asp
孟子E章 2004-08-02
  • 打赏
  • 举报
回复
我这里有源代码,要的话留email
孟子E章 2004-08-02
  • 打赏
  • 举报
回复
你搜索一个lyfupload,油现成的

863

社区成员

发帖
与我相关
我的任务
社区描述
VB COM/DCOM/COM+
c++ 技术论坛(原bbs)
社区管理员
  • COM/DCOM/COM+社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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