upfile.asp
上传用户:yjkj1008
上传日期:2020-10-17
资源大小:1496k
文件大小:2k
源码类别:

电子政务应用

开发平台:

HTML/CSS

  1. <!--#include FILE="upload.inc"-->
  2. <html>
  3. <head>
  4. <title>文件上传</title>
  5. <script  language="JavaScript">
  6. <!-- Hide from older browsers...
  7. //Function to add pic
  8. function Addpic(imagePath){
  9. window.opener.frames.message.focus();
  10. window.opener.frames.message.document.execCommand('InsertImage', false, imagePath);
  11. window.close();
  12. }
  13. // -->
  14. </script>
  15. </head>
  16. <LINK href=site.css rel=stylesheet>
  17. <%
  18. dim upload,file,formName,formPath,iCount,filename,fileExt,path
  19. set upload=new upload_5xSoft ''建立上传对象
  20.  path = Request.ServerVariables("HTTP_REFERER")
  21.  path = replace(path,"upload.asp","")
  22.  formPath=upload.form("filepath") ''在目录后加(/)
  23.  if right(formPath,1)<>"/" then formPath=formPath&"/" 
  24. response.write "<BODY bgColor=menu topmargin=15 leftmargin=15 ><br>"
  25. iCount=0
  26. for each formName in upload.file ''列出所有上传了的文件
  27.  set file=upload.file(formName)  ''生成一个文件对象
  28.  if file.filesize<100 then
  29.   response.write "<FIELDSET align=center><LEGEND align=center>文件上传发生错误 </LEGEND><br>请先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</fieldset>"
  30. response.end
  31.  end if
  32.  
  33.  if file.filesize>200000 then
  34.   response.write "<FIELDSET align=center><LEGEND align=center>文件上传发生错误 </LEGEND><br>文件大小超过了限制 200K [ <a href=# onclick=history.go(-1)>重新上传</a> ]</fieldset>"
  35. response.end
  36.  end if
  37.  fileExt=lcase(right(file.filename,4))
  38.  if fileEXT<>".gif" and fileEXT<>".jpg" and fileEXT<>".png" and fileEXT<>".bmp" then
  39.   response.write "<FIELDSET align=center><LEGEND align=center>文件上传发生错误</LEGEND><br>文件格式不正确  [ <a href=# onclick=history.go(-1)>重新上传</a> ]</fieldset>"
  40. response.end
  41.  end if 
  42.  randomize
  43.  ranNum=int(90000*rnd)+10000
  44.  filename=formpath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&fileExt
  45.  
  46. ' filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&file.FileName
  47.  
  48.  if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
  49.   file.SaveAs Server.mappath(FileName)   ''保存文件
  50.  iCount=iCount+1
  51.  end if
  52. fpath=Server.mappath(FileName)
  53.  set file=nothing
  54. next
  55. set upload=nothing  ''删除此对象
  56. Htmend iCount&" 个文件上传结束!"
  57. sub HtmEnd(Msg)
  58.  set upload=nothing
  59.  response.write "<center><FIELDSET align=center><LEGEND align=center><font color=red>文件上传成功 </font></LEGEND><br>[ <a href=# onclick=""Addpic('"&path&filename&"')"">点击这里添加到编辑器中</a> ]</fieldset>"
  60. response.end
  61. end sub
  62. %>
  63. </body>
  64. </html>