找了个上传文件的html

来源:互联网 发布:电脑左上角显示数据 编辑:程序博客网 时间:2024/05/08 19:01


<!DOCTYPE html>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>定义input type="file" 的样式</title>

<!--用CSS,样式-->

<style type="text/css">

body{ font-size:14px;}

/*垂直对齐*/

input{ vertical-align:middle; margin:0; padding:0}
.file-box{ position:relative;width:340px}
.txt{ height:22px; border:1px solid #cdcdcd; width:180px;}

.btn{ background-color:#FFF; border:1px solid #CDCDCD;height:24px; width:70px;}

/*opacity不透明*/

.file{ position:absolute; top:0; right:80px; height:24px; filter:alpha(opacity:0);opacity: 0;width:260px }
</style>
</head>
<body>
<div class="file-box">
  <form action="" method="post" enctype="multipart/form-data">
 <input type='text' name='textfield' id='textfield' class='txt' />  

 <input type='button' class='btn' value='浏览...' />

<!--<input type="file"是一个控件,有个按钮和一个text输入框。这里是将这个控件隐藏了,用上面的代替。用上面的text来显示file选择的文件-->

    <input type="file" name="fileField" class="file" id="fileField" size="28" onchange="document.getElementById('textfield').value=this.value" />
 <input type="submit" name="submit" class="btn" value="上传" />
  </form>
</div>
</body>
</html>
0 0
原创粉丝点击