document.write('

 解析:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<style type="text/css">
._box
{
position: relative;
width: 119px;
height: 37px;
background-color: #53AD3F;
background-image: url(images/bg.png);
background-repeat: no-repeat;
background-position: 0 0;
background-attachment: scroll;
line-height: 37px;
text-align: center;
color: white;
cursor: pointer;
overflow: hidden;
z-index: 1;
}
._box input
{
position: absolute;
width: 119px;
height: 40px;
line-height: 40px; 
font-size: 23px;
opacity: 0;
filter: "alpha(opacity=0)";
filter: alpha(opacity=0);
-moz-opacity: 0;
left: -5px;
top: -2px;
cursor: pointer;
z-index: 2;
}
</style>
<title>js 实现 input file 文件上传 /></title>
</head>
<body>
<form id="form1" runat="server" method="post"
enctype= "multipart/form-data">
<div>
<div class="_box">
<input type="file" name="_f" id="_f" />
选择图片
</div>
</div>
</form>
</body>
</html> 用一个不透明度为 0 的 <input type="file"/> 盖在要让用户可见的标
签(或图片)上,让用户单击。
【总结】
用 width height line-height font-size 来控制 <input type="file"/> 右侧浏览器按
钮的大小。用 left top(right、bottom) 来控制 <input type="file"/> 右侧浏览器按钮
的位置,可以设置为负值。用 -index 来设置它们的层覆盖关系。From 必须有
enctype="multipart/from-data" 标记才能上传文件。
');