First, the picture can look for the selection in the page. Design Form Page INDEX.ASP and Upload Selection Page Upload.asp, Upload.asp In IFRAME in Index.asp. Second, the selected picture should be able to upload a folder. Create a folder UPLOADIMG Finally, how should the picture be referenced? Obviously, UBB is used immediately. UPLOAD.ASP's pointing object UpFile.asp has the function of writing UBB tags. The picture was uploaded with the non-component uploaded by Daoxiang old agriculture. So UPLOAD.INC file is essential. 1. Upload.inc (copy all code of the following text box)
DIM UPFILE_5XSOFT_STREAM
Class Upload_5xsoft
DIM FORM, FILE, VERSION
Private sub coplass_initialize
DIM ISTART, INILENAMESTART, IEND, VBENTER, IELORMSTART, IFORMEND, Thefile
DIM STRDIV, MFormName, MFormValue, Mfilename, Mfilesize, MfilePath, ID VLLEN, MSTR
Version = ""
IF Request.Totalbytes <1 the EXIT SUB
SET form = createObject ("scripting.dictionary")
Set file = creteObject ("scripting.dictionary")
SET UPFILE_5XSOFT_STREAM = CREATEOBJECT ("AdoDb.Stream")
UPFILE_5XSOFT_STREAM.MODE = 3
UPFILE_5XSOFT_STREAM.TYPE = 1
UPFILE_5XSOFT_STREAM.Open
Upfile_5xsoft_stream.write request.binaryRead (Request.Totalbytes)
vbenter = chr (13) & chr (10)
IDIVLEN = Instring (1, vtribenter) 1
Strdiv = Substring (1, ID VLLEN)
IFORMSTART = ID VLLEN
IFORMEND = Instring (iformstart, strdiv) -1
While iFormStart iStart = Instring (iformstart, "Name =" "") IEND = Instring (iStart 6, "" ") MFORMNAME = Substring (iStart 6, Iend-iStart-6) Ifilenamestart = Instring (IEND 1, "FileName =" "") If iFilenamestart> 0 and ifilenamestart Ifilenamend = Instring (ifilenamestart 10, "" "") MfileName = Substring (ifilenamestart 10, ifilenameend-iFileNameStart-10) iStart = Instring (ifilenameend 1, Vtribenter & Vtrib IEND = Instring (iStart 4, vtribenter & strdiv) if Ind> iStart Then MfileSize = IEND-IEND-ISTART-4 Else Mfilesize = 0 END IF Set thefile = new fileInfo Thefile.FileName = GetFileName (MfileName) Thefile.FilePath = getFilePath (MfileName) Thefile.filesize = mfilesize Thefile.FileStart = iStart 4 Thefile.FormName = formname File.add MFormName, Thefile Else iStart = Instring (IEND 1, VBENTER & VBENTER) IEND = Instring (iStart 4, Vtribenter & Strdiv) INEND> iStart Then MFORMVALUE = Substring (iStart 4, IEND-ISTART-4) Else MFORMVALUE = "" " END IF Form.Add MFormName, MFormValue END IF IFORMStart = IFORMEND IDIVLEN IFORMEND = Instring (iformstart, strdiv) -1 Wend End Sub Private Function Substring (Theestart, Thelen) DIM I, C, STEMP Upfile_5xsoft_stream.position = thisstart-1 STEMP = "" For i = 1 to thelen IF Upfile_5xsoft_Stream.eos Then Exit for C = ASCB (Upfile_5xsoft_stream.read (1)) IF C> 127 THEN IF Upfile_5xsoft_Stream.eos Then Exit for STEMP = STEMP & CHR (ASCW (ASCB (ASCB (Upfile_5xsoft_Stream.read (1))) & chrb (c)))) i = i 1 Else STEMP = STEMP & CHR (C) END IF NEXT Substring = STEMP END FUNCTION Private function Instring (TheestArt, Varstr) DIM i, J, BT, THELEN, STR INSTRING = 0 Str = Tobyte (Varstr) THELEN = LeNB (STR) For i = thistart to upfile_5xsoft_stream.size-thelen IF i> Upfile_5xsoft_stream.size the exit function UPFILE_5XSOFT_STREAM.PSITION = I-1 IF ASCB (Upfile_5xsoft_Stream.read (1)) = ASCB (MIDB (Str, 1)) THEN Instring = i For j = 2 to thelen IF Upfile_5xsoft_stream.eos Then INSTRING = 0 EXIT for END IF IF ASCB (Upfile_5xsoft_Stream.read (1)) <> ASCB (MIDB (Str, J, 1)) THEN INSTRING = 0 EXIT for END IF NEXT IF Instring <> 0 THEN EXIT FUNCTION END IF NEXT END FUNCTION Private sub coplass_terminate Form.removeall File.removeall SET form = Nothing Set file = Nothing UPFILE_5XSOFT_STREAM.CLOSE SET UPFILE_5XSOFT_STREAM = Nothing End Sub Private function getFilePath (Fullpath) IF Fullpath <> "" "" " GetFilePath = Left (Fullpath, INSTRREV (Fullpath, "/"))) Else GetFilePath = "" END IF END FUNCTION Private function getFileName (Fullpath) IF Fullpath <> "" "" " GetFileName = MID (Fullpath, Instrrev (Fullpath, "/") 1) Else GetFileName = "" " END IF END FUNCTION Private function Tobyte (STR) DIM I, ICODE, C, ILOW, IHIGH Tobyte = "" For i = 1 to Len (STR) C = MID (STR, I, 1) ICODE = ASC (C) IF iCode <0 Then icode = icode 65535 IF icode> 255 THEN iLow = left (HEX (ASC (C)), 2) ihigh = Right (HEX (ASC (C)), 2) Tobyte = Tobyte & Chrb ("& H" & ilow) & chrb ("& H" & ihigh) Else Tobyte = Tobyte & ChRB (ASCB (C)) END IF NEXT END FUNCTION END CLASS Class fileInfo DIM FORMNAME, FILENAME, FILEPATH, FILSIZE, FILESTART Private sub coplass_initialize FILENAME = "" Filepath = "" " FILESIZE = 0 FILESTART = 0 Formname = "" End Sub Public Function Saveas (Fullpath) DIM DR, ERRORCHAR, I SaveAs = 1 If Trim (Fullpath) = "" or FileSize = 0 or filestart = 0 or filename = "" "THEN EXIT FUNCTION IF fileStart = 0 or Right (Fullpath, 1) = "/" THEN EXIT FUNCTION Set Dr = CreateObject ("AdoDb.Stream") Dr.Mode = 3 Dr.TYPE = 1 Dr.open Upfile_5xsoft_stream.position = filestart-1upfile_5xsoft_Stream.couthto DR, FileSize Dr.savetofile Fullpath, 2 Dr.close SET DR = Nothing SaveAs = 0 END FUNCTION END CLASS Script> [Ctrl a All Select Tips: You can modify some code first, then press Run] 2, the table INDEX.ASP. Note the upload selection page UPLOAD.ASP
hEAD>
Parent.document.forms [0] .submit.disabled = false;
script>
<%
DIM UPLOAD, FORMNAME, FORMPATH, ICOUNT, FILENAME, FILEEXT
Set upload = new upload_5xsoft '' Create upload objects
FormPath = UPLOAD.FORM ("FilePath")
'' After the directory (/)
IF Right (FormPath, 1) <> "/" THEN FORMPATH = FormPath & "/"
Response.write "
"ICOUNT = 0
For each formname in Upload.file '' lists all uploaded files
Set file = UPLOAD.FILE (FORMNAME) '"Generates a file object
IF file.filesize <100 THEN
Response.write "Please select the file you want to upload []"
Response.end
END IF
IF file.filesize> 100 * 1000 THEN
Response.write "file size exceeds limit 100K []"
Response.end
END IF
FileExt = LCase (Right (file.filename, 4))
Uploadsuc = false
Forum_UPLOAD = "GIF, JPG, PNG"
ForumUPLOAD = Split (forum_upload, ",")
For i = 0 to Ubound (forumupload)
If FileExt = "." & TRIM (Forumupload (i)) THEN
Uploadsuc = TRUE
EXIT for
Else
Uploadsuc = false
END IF
NEXT
IF uploadsuc = false kil
Response.write "file format is incorrect []"
Response.end
END IF
randomize
Rannum = int (90000 * rND) 10000
FileName = FormPath & Year (now) & DAY (now) & Hour (now) & minute (now) & second (now) & rannuM & FileExt
If File.FileSize> 0 Then '' If FileSize> 0 Description Document Data
File.SAVEAS Server.mappath (filename) '' Save File
For i = 0 to Ubound (forumupload)
If FileExt = "." & TRIM (Forumupload (i)) THEN