日期:2013-02-27  浏览次数:20931 次

其中部分代码根据化境代码改编!!
upload.htm
<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
<link rel="stylesheet" href="../public/css.css">
</head>
<script language="javascript">
<!--
function checkform1()
  {

  if (form1.names.value=="")
    {
    alert("请输入名称!")
    form1.names.focus()
    return false
    }
  if (form1.pic.value=="")
    {
    alert("请选择图片!")
    form1.pic.focus()
    return false
    }
  return true
  }

//-->
</script>
<body>

<table border="0" width="100%">
<form name="form1" enctype="multipart/form-data" action="upload.asp" method="post" onsubmit="return checkform1()">
  <tr>
    <td width="100%" colspan="2">
      <p align="center"><b>上传示例</b></td>
  </tr>
  
  <tr>
    <td width="40%" align="right">名称:</td>
    <td width="60%"><input type="text" name="names" size="30" maxlength="20" class="input1"></td>
  </tr>
  <tr>
    <td width="40%" align="right">图样:</td>
    <td width="60%"><input type="file" name="pic" size="30" maxlength="20" class="input1"  onblur="document.all.picview.src=document.all.pic.value"></td>
  </tr>
  
  <tr>
    <td width="40%" align="right"> </td>
    <td width="60%"><input  type="submit" value="   o k   " class="inputbtn"></td>
  </tr>
  <tr>
    <td width="100%" align="center" colspan="2">
    图象预览(选择图片后,点击页面任意处即可进行预览)<br>
    <img id="picview" border="1">
    </td>
    
  </tr>
  </form>
</table>

</body>

</html>


-----upload.asp
<!--#include file="savefile.asp"-->
<%
Set objStream = Server.CreateObject("ADODB.Stream")
  
  objstream.mode=3
  objStream.Type = 1
  objStream.Open
  
  objstream.write Request.BinaryRead(Request.TotalBytes)
  
  names= getvalue("names",true,"")
  
  pic=getvalue("pic",false,"upimg/")