两个文件放在一起,文件保存到upfile目录下。
upfile.asp
<% @codepage=936 EnableSessionState=False%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>上传测试页</title> </head>
<body> <script> function checkForm(){ if(fileForm.file1.value==""){ alert("请选择文件。"); return false; } return true; } </script> <form name="fileForm" method="post" action="saveFile.asp" enctype="multipart/form-data" onSubmit="return checkForm();">
File:<INPUT name="file1" type="file" size="20"> 请小于2M<br> <input name="Submit" type="submit" class="myButton" value="开始上传"> </form> </body> </html>
saveFile.asp
<% @codepage=936 EnableSessionState=False%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>上传结果</title> </head>
<body> <% Server.ScriptTimeOut=300 Set oFileUp = Server.CreateObject("SoftArtisans.FileUp") formPath="upfile/" '文件保存位置
if oFileUp.Form("file1").TotalBytes>1024 *1024 *2 then errMsg=errMsg+"文件:"&oFileUp.Form(strFormElement).UserFileName&" 大于2M!<br>" else strShortFileName = mid(oFileUp.Form("file1").UserFileName,InStrRev(oFileUp.Form("file1").UserFileName, "\")+1) '取得文件名 oFileUp.Form("file1").SaveInVirtual formPath & strShortFileName '保存文件 errMsg="save ok. <input type='button' value='..back..' onClick='history.go(-1);'" end if response.write errMsg %> </body> </html>
|