tr> form>
TABLE>
TABLE>
TABLE>
body>
html>
Fupload.inc
'Limiting upload image size
DIM UPLOADSIZELIMIT
'*************************************************************************************** *********************
Function gameupload ()
Dim Result
Set result = Nothing
If Request.servervariables ("Request_Method") = "post" The 'Request Method Must Be "Post"
DIM CT, POSB, Boundary, Length, Pose
CT = Request.SerVariables ("http_content_type") 'Reads Content-Type Header
IF Lcase (Left (CT, 19)) = "Multipart / Form-Data" Then 'Content-Type Header Must Be "Multipart / Form-Data"
'This is upload.
'Get the boundary and length from content-type header
POSB = INSTR (LCase (CT), "Boundary =") 'FINDS Boundary
IF POSB> 0 THEN Boundary = MID (CT, POSB 9) 'Separetes Boundary
Length = clng ("http_content_length")) 'Get Content-Length Header
IF "" & Uploadsizelimit <> "" "" "
UPLOADSIZELIMIT = CLNG (Uploadsizelimit)
IF Length> Uploadsizelimit Then
'on Error ResMe next' Clears the Input Buffer
'Response.addheader "Connection", "Close"
'on Error Goto 0
Request.binaryRead (Length)
Err.raise 2, "Getupload", "Upload Size" & FormatNumber (Length, 0) & "B Exceeds Limit of" & FormatNumber (Uploadsizelimit, 0) & "B"
EXIT FUNCTION
END IF
END IF
If Length> 0 and boundary <> "" "" Are The Required Informations ABOUT UPLOAD?
Boundary = "-" & boundary
Dim head, binary
Binary = Request.binaryRead (Length) 'Reads Binary Data from Clom Clom Clom Clom Clom Clom
'Retrieves the Upload Fields from Binary Data
SET Result = SeparateFields (Binary, Boundary)
Binary = Empty 'Clear Variables
Else
Err.raise 10, "Getupload", "Zero Length Request."
END IF
Else
Err.raise 11, "Getupload", "No File Sent."
END IF
Else
Err.raise 1, "Getupload", "Bad Request Method."
END IF
Set getupload = result
END FUNCTION
Function Separatefields (binary, boundary)
Dim Posopenboundary, Poscloseboundary, Posndofheader, IslastBoundary
DIM Fields
Boundary = StringTobinary (Boundary)
Posopenboundary = INSTRB (Binary, Boundary)
PosCloseboundary = INSTRB (Posopenboundary Lenb (Boundary), Binary, Boundary, 0) Set Fields = CreateObject ("scripting.dictionary")
Do While (Posopenboundary> 0 and Poscloseboundary> 0 and not islastboundary)
'Header and File / Source Field Data
Dim HeaderContent, FieldContent
'Header Fields
DIM Content_Disposition, FormfieldName, SourceFileName, Content_Type
'Helping Variables
Dim Field, TwoCharsafterendBoundary
'Get End of HEADER
Posndofheader = INSTRB (Posopenboundary Len (Boundary), Binary, StringTobinary (VBCRLF VBCRLF))
'Separates Field HEADER
HeaderContent = MIDB (Binary, Posopenboundary Lenb (Boundary) 2, PosopenBoundary - Lenb (Boundary) - 2)
'Separates Field Content
FieldContent = MIDB (Binary, (Posndofheader 4), Poscloseboundary - (Posndofheader 4) - 2)
'Separates Header Fields from Header
GetHeadfields BinaryTostring (HeaderContent), Content_Disposition, FormfieldName, SourceFileName, Content_Type
'Create ONE Field and Assign Parameters
SET FIELD = CREATEUPLOADFIELD ()
Field.name = formfieldname
Field.contentdisPosition = Content_DisPosition
Field.FilePath = SourceFileName
FIELD.FILENAME = GetFileName (SourceFileName)
FIELD.CONTENTTYPE = Content_Type
Field.Value = FieldContent
Field.Length = lenb (fieldcontent)
Fields.add FormfieldName, Field
'Is this Ending Boundary?
TwocharsafterendBoundary = binarytostring (MIDB (Binary, Poscloseboundary lenb (boundary), 2))
'Binary.mid (PosCloseboundary Len (Boundary), 2) .string
IslastBoundary = twocharsafterendboundary = "-"
IF not islastboundary the 'this is not ending boundary - go to next form field.posopenboundary = Poscloseboundary
PosCloseboundary = INSTRB (Posopenboundary lenb (boundary), binary, boundary
END IF
Loop
Set SeparateFields = Fields
END FUNCTION
'******************************** UTILITIES ************** *******************
Function BinaryToString (STR)
STRTO = ""
For i = 1 to lenb (STR)
IF ASCB (MIDB (STR, I, 1)> 127 THEN
STRTO = STRTO & CHR (ASCB (MIDB (STR, I, 1)) * 256 ASCB (MIDB (STR, I 1, 1))))
i = i 1
Else
STRTO = STRTO & CHR (ASCB (MIDB (STR, I, 1)))))
END IF
NEXT
BinaryToString = STRTO
END FUNCTION
Function StringTobinary (String)
DIM I, B
For i = 1 to len (string)
B = B & ChRB (ASC (MID (String, I, 1))))
NEXT
StringTobinary = B
END FUNCTION
'Separates Header Fields from Upload HEADER
Function Getheadfields (Byval Head, Content_Disposition, Name, FileName, Content_Type)
Content_disposition = LTRIM (Separatefield (Head, "Content-Disposition:", ";")
Name = (Separatefield (Head, "Name =", ";")) 'Ltrim
If Left (Name, 1) = "" "" "" "" "" "", 2, len (name) - 2)
FileName = (Separatefield (Head, "FileName =", ";")) 'Ltrim
IF Left (FileName, 1) = "" "" "" "", 2, Len (filename) - 2)
Content_type = LTRIM (Separatefield (Head, "Content-Type:", ";"))
END FUNCTION
'Separets One Filed Between SSTART and SEND
Function Separatefield (from, byval sstart, byval send)
Dim Posb, Pose, Sfrom
sfrom = lcase (from)
POSB = INSTR (SFROM, SSTART)
IF POSB> 0 ThenPOSB = POSB LEN (SSTART)
Pose = INSTR (POSB, SFROM, SEND)
IF pose = 0 Then Pose = INSTR (POSB, SFROM, VBCRLF)
If Pose = 0 Then Pose = LEN (SFROM) 1
SeparateField = MID (from, POSB, POSE - POSB)
Else
SeparateField = EMPTY
END IF
END FUNCTION
'Separetes File Name from The Full Path Of File
Function GetFileName (Fullpath)
DIM POS, POSF
POSF = 0
For POS = LEN (FULLPATH) TO 1 Step -1
Select Case Mid (Fullpath, POS, 1)
Case "/", "/": POSF = POS 1: POS = 0
End SELECT
NEXT
IF POSF = 0 THEN POSF = 1
GetFileName = MID (Fullpath, POSF)
END FUNCTION
Script>
// The function creates field Object.
Function createuploadfield () {return new uf_init ()}
Function uf_init () {
this.name = NULL
this.contentdisPosition = NULL
this.FileName = NULL
this.filepath = NULL
this.contentType = NULL
THIS.VALUE = NULL
this.Length = NULL
}
Script>
Addphoto.asp
<%
If Request.servervariables ("Request_Method") = "post" then
DIM Fields
UPLOADSIZELIMIT = 100000
Set Fields = getupload ()
DIM Field
For Each Field in Fields.Items
Select Case Field.name
Case "thetext" sss = binarytostring (Field.Value)
Case "Type" fff = binarytostring (field.value)
Case "Submit" Submit = binarytostring (field.value)
Case "PIC"
FILENAME = Field.FileName
FILECONTENTTYPE = Field.ContentType
FileValue = Field.ValueEnd SELECT
NEXT
'---------------
IF filename <> "" and filecontettype <> "image / gif" and
FileContentType <> "image / pjpeg" THEN
%>
The uploaded photo should be a GIF or JPG file! Font>
True; ">
center>
<%
Else
'--------------
'Start input
'-----------
Response.write SSS
Response.write " "
Response.write fff
SET RS = Server.createObject ("AdoDb.Recordset")
SQL = "SELECT * from Tb Where Theid is Null"
RS.Open SQL, CONN, 3, 3
rs.addnew
RS ("Author) = UserName
RS ("ThetExt") = SSS
RS ("Types") = fff
RS ("HITS") = 1
RS ("posttime") = now ()
RS ("photo"). Appendchunk FileValue
Rs.Update
Rs.close
%>
Size = 3> Enter personal basic files successfully! Font> |