Using the file upload feature in WebClass

Source: Internet
Author: User
Tags define exit define local error handling file upload variables
web| upload in WebClass using file Upload function

WebClass Example: http://www.shinco.com/jjx/wcnews/news.asp
Many file upload components can not be used in VB normal use, I tested the chinaasp fileup,aspsmartupload,aspupload enterprise,inotesupload and other components, can not be
Often used. The main reason is that there is no onstartpage process of the component in VB. We can not rewrite these components, so we have to code to solve this problem, remember that a previous netizen talked about this problem, but no code posted.
In fact, there used to be a chinaasp of the components of the Web upload file (I can't find it, this is my posting address http://www.shinco.com/jjx/activeubb/NewsDetail.asp?id=134, A slight rewrite will be used in the WebClass.

Change the original OnStartPage process to
Public Sub OnStartPage (passedrequest as Request)

'------------------define local variables----------------------
Dim Varbytecount
Dim I
'---------------------------------------------------

'------------------build an ASP object-----------------------
Set myrequest = passedrequest
'---------------------------------------------------

'------------------read all the data that came from the client-----------
Varbytecount = Myrequest.totalbytes
Lngarraylen = varByteCount-1
ReDim BinArray (varByteCount-1)
BinArray = Myrequest.binaryread (Varbytecount)
'---------------------------------------------------

'--------------------get the delimiter---------------------
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

Using in WebClass

Dim upload As New UploadFile
Upload.onstartpage (Request)

Then you can use the method provided by this class to operate, the function of this component is worse than chinaasp upload. But it's enough to use.

Other changes

1, in order to be able to use the Getthevalue method to get the input type of the value of Checkbox,radio,

Add error handling in Findthename
Private Function findthename (nm as String) as Long
On Error GoTo Findthenameerror
' ****************************** parameter Description *****************************
'* *
' * NM: The name of the Form element to look for *
' * Return Value: Success-when found address, failed ——-1 *
'* *
'*******************************************************************

'------------------define local variables----------------------
Dim S as Long
Dim e as Long
Dim I as Long

Dim bintmp () as Byte
Dim StrName as String
'---------------------------------------------------

'------------------look for the name of the form element to get the value------------------------
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, delete the class declaration
Private Myscriptingcontext as ScriptingContext definition






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.