Today I saw the procedure of uploading the progress bar on the Internet. Try it, the effect is good. Now I will be placed here to share with you.
<!-#Include file = Sundyupload.asp->
< %
'The encoding of this example is UTF-8. If it is a system of other codes, please convert the encoding into the corresponding encoding, otherwise the form obtaining data may be garbled
Dia Objupload, OPT
DIM XMLPATH
DIM FILEFORMNAME, OBJFILE, Counter
opt = request.querystring (opt)
If opt = upload then
xmlpath = server.mappath (request.querystring (xmlpath) '' to convert the virtual path to the actual path
Set objupload = New Sundyupload '
Objupload.uploadinit xmlpath, UTF-8
counter = 1
Response.write (common form: & objupload.form (normalForm) & <br> <br>) 'Get the form data
For Each FileFormname in Objupload.objfile
Set objfile = Objupload.objfile (FileFormname)
filesize = objfile.filesize
strtemp = objfile.filepath
Response.write strtemp
filename = MID (StrTemp, Instrrev (StrTemp, /)+1)
'G0 =
f0 = replace (replace (replace (now (),:),),),),) & g0
If filesize> 0 then
Response.write (File Size: & Filesize & <br>)
Response.write (File name: & objfile.filepath & <br>)
t = split (filename ,.)
t1 = t (1)
filename = Replace (Replace (Replace (now,:,),),-,) & t1
'Response.write (File Description: & Objupload.form (FileDesc & Counter) & <br> <br>)
objfile.saveas server.mappath (.) & / upload / & file
Response.write Save at: & Server.MAPPATH (.) & / UPLOAD / & Filename & <br> <br> <br>
End if
counter = counter + 1
Next
End if
'Specify the virtual path for the uploaded progress bar data file (the XML file specifies the virtual path)
'It is best to be random, because multiple people may upload at the same time, and different progress data requires different progress data
'This path needs to be transmitted into the uploaded component when submitting, so that the data is changed during the uploading process
'The client uses JavaScript to read this XML file to display the progress
xmlpath = upload/ & timer & .xml
%>
<html>
<head>
<meta http-equiv = content-type content = text /html; charset = utf-8 />
<Title> Sundy Upload Progress Bar Example </Title>
<script language = javascript>
Function chkfrm () {
var objfrm = document.frmupload;
if (objfrm.file1.value == && objfrm.file2.value ==) {
Alert (please select a file);
objfrm.file1.focus ();
Return false;
}
objFRM.ACTION = Example.asp? OPT = UPLOAD & XMLPATH = <%= Xmlpath%>;
startprogress ('<%= xmlpath%>'); // Start the progress bar
Return true;
}
</script>
</head>
<body>
<FORM NAME = FRMUPLOAD METHOD = Post Action = Example.asp EnCTYPE = Multipart/Form-Data OnSubmit = Return chkfrm ()>
Ordinary form: <br> <input type = text name = normalform size = 40> <br> <br>
File 1: <br>
<input type = file name = file1 size = 40> </br>
<input type = text name = filedesc1 size = 30> <br> <br>
File 2: <br>
<input type = file name = file2 size = 40> </br>
<input type = text name = filedesc2 size = 30> <br>
File 3: <br>
<input type = file name = file3 size = 40> </br>
File 4: <br>
<input type = file name = file4 size = 40> </br>
File 5: <br>
<input type = file name = file5 size = 40> </br>
<input type = submit name = btnsubmit value = submit/>
</form>
</body>
</html>