|
导读在webclass中使用文件上传功能webclass实例:http://www.shinco.com/jjx/wcnews/news.asp许多文件上传组件并不能在vb中正常使用,我测试了china... 在webclass中使用文件上传功能webclass实例:http://www.shinco.com/jjx/wcnews/news.asp 许多文件上传组件并不能在vb中正常使用,我测试了chinaasp fileup,aspSmartupload,aspupload enterprise,inotesupload等组件,均不能正 常使用。其主要原因,是因为在vb中没有促发组件的OnStartPage过程。我们无法改写这些组件,所以要自己编码来解决这个问题,记得以前有网友谈过这个问题,但没有代码贴出来。 其实以前chinaasp上有个编写web方式上载文件的组件的贴子(我一下找不了,这是我转贴的地址http://www.shinco.com/jjx/activeubb/NewsDetail.asp?id=134,稍微改写一下就能在webclass中使用了 将原onstartpage过程改为 Public Sub OnStartPage(PassedRequest As Request) '------------------定义局部变量---------------------- Dim varByteCount Dim i '--------------------------------------------------- '------------------建立ASP对象----------------------- Set MyRequest = PassedRequest '--------------------------------------------------- '------------------读取客户端传来的全部数据----------- 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 在webclass中使用 dim upload as new uploadfile upload.onstartpage(request) 然后就可以用该类提供的方法了进行操作了,这个组件的功能比chinaasp upload要差些。但已经足够使用了 其他改动 1、为了能用getthevalue方法正确取得input type 为checkbox,radio等的值,在 FindtheName中加入错误处理 Private Function FindTheName(nm As String) As Long On Error GoTo FindTheNameError '******************************参数说明***************************** '* * '* 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 '-------------------------------------------------------------- Exit Function FindTheNameError: FindTheName = -1 End Function 2、删除类声明中的 Private MyScriptingContext As ScriptingContext定义 |
温馨提示:喜欢本站的话,请收藏一下本站!