Example:
- ============== fileup.htm start =====================================
- <HTML><BODY>
- <FORM ACTION="fileup.asp" ENCTYPE="multipart/form-data" METHOD=POST>
- Name: <INPUT TYPE=TEXT NAME="yourname"><BR>
- File1: <INPUT TYPE=file NAME="file1"><BR>
- File2: <INPUT TYPE=file NAME="file2"><BR>
- <INPUT TYPE=SUBMIT NAME=UPLOAD>
- </FORM></BODY></HTML>
- ============== fileup.htm end ========================================
- ============== fileup.asp start =====================================
- <%
- a=Request.TotalBytes
- b=Request.BinaryRead(a)
- set obj=server.createobject("basp21")
- name=obj.Form(b,"yourname")
- f1=obj.FormFileName(b,"file1")
- f2=obj.FormFileName(b,"file2")
- fsize1=obj.FormFileSize(b,"file1")
- fsize2=obj.FormFileSize(b,"file2")
- newf1=Mid(f1,InstrRev(f1,"\")+1)
- newf2=Mid(f2,InstrRev(f2,"\")+1)
- l1=obj.FormSaveAs(b,"file1","e:\temp\log\" & newf1)
- l2=obj.FormSaveAs(b,"file2","e:\temp\log\" & newf2)
- %>
- <HTML><HEAD><TITLE>File Upload Test</TITLE>
- <BODY>
- <H1>Testing</H1>
- <BR>
- Dear <%= name %>; Your file has been uploaded<BR>
- file1= <%= newf1 %><BR>
- file2= <%= newf2 %><BR>
- len1= <%= l1 %><BR>
- len2= <%= l2 %><BR>
- </BODY></HTML>
- ============== fileup.asp end =====================================
Those of you, who are using Internet Explorer 3.02,
and could not see Browse Button at fileup.htm,
you need to install 3.02 File Upload Add-On from Microsoft.
使用basp21上传文件的时候,保存的文件的目录必须存在,如上面的例子中,仅仅存在e:\temp都是不行的,必须存在e:\temp\log才能上传成功。
阅读(2996) | 评论(0) | 转发(0) |