不用文本上传控件可以上传文件吗?该如何解决
不用文本上传控件可以上传文件吗????急
我正在做一个图片上传功能。由于在不同浏览器之间文件上传控件样式不一样。请有办法让它一样,或者不用文本上传控件同样可以上传文件吗???
------解决方案--------------------
不是有<input type="file">吗
------解决方案--------------------
你可以模拟通过CSS来控制模拟input file的样式,比如
我正在做一个图片上传功能。由于在不同浏览器之间文件上传控件样式不一样。请有办法让它一样,或者不用文本上传控件同样可以上传文件吗???
------解决方案--------------------
不是有<input type="file">吗
------解决方案--------------------
你可以模拟通过CSS来控制模拟input file的样式,比如
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
input{float:left;margin:0;padding:0;background:none;border:none; }
.upload{ width:300px;height:40px;line-height:40px;position:relative;font-size:18px; overflow:hidden;}
.upload .text{width:220px;border:solid 1px #ccc;height:22px;line-height:22px;}
.upload .file{position:absolute;top:0;right:0;width:100%;height:24px;border:solid 1px #ccc;opacity:0;filter:alpha(opacity=0);cursor:pointer;}
.upload span{float:right;width:60px;height:24px;line-height:24px;background:#09C;color:#fff; text-align:center;cursor:pointer; border-radius:5px; }
</style>
</head>
<body>
<div class="upload">
<input type="text" class="text" id="txtfile"/>
<span>上传</span>
<input type="file" class="file" onchange="document.getElementById('txtfile').value=this.value;"/>
</div>
</body>
</html>