<!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=gb2312" />
<title>input file的另类做法</title>
<style type="text/css">
<!--
* { font-size:12px}
body { margin:0}
.line { position:relative; float:left; padding:8px 0}
.line span { float:left}
input { border:1px solid #888; vertical-align:middle}
.file { position:absolute; left:90px; top:8px; display:none;filter:alpha(opacity=0);opacity:0}
.file1 { padding:2px 10px; display:block; float:left; background:#FF66CC; color:#fff; z-index:1; margin-left:5px; vertical-align:middle; cursor: pointer}
.inputstyle { width:150px; border:1px solid #888; z-index:99}
-->
</style>
</head>
<body>
<div class="line">
<span>
<label>上传文件:</label>
<input name="" type="text" id="viewfile" onmouseout="document.getElementById('upload').style.display='none';" class="inputstyle" onchange="alert(this.value);"/>
</span>
<label for="unload" onmouseover="document.getElementById('upload').style.display='block';" class="file1">
添加附件
</label>
<input type="file" onchange="document.getElementById('viewfile').value=this.value;this.style.display='none';" class="file" id="upload" />
</div>
</body>
</html>
分享到:
相关推荐
标签中的"另类其它 控件 源码 资源"可能意味着这个压缩包包含了非主流的编程技巧、自定义控件的实现、源代码示例以及可能的资源文件。例如,`drawsamp.exe`可能是演示某个图形绘制算法的可执行程序,`Form1.frm`和`...
<input type="file" name="myfile[]" multiple> <input type="submit" value="上传"> ``` 这里的`enctype="multipart/form-data"`是关键,它允许我们上传文件。 二、处理文件上传的PHP代码 在PHP端,我们可以...
此外,还需要一个`<input type="file">`元素让用户选择文件。 2. PHP处理脚本:接收到文件后,PHP脚本会进行一系列验证,例如检查文件大小是否超过设定限制,文件类型是否被允许等。这些验证可以通过PHP内置的函数...
`<input type="file" multiple>`标签可以开启多选模式,让用户一次性选取多个文件。 - **Ajax异步上传**: 使用Ajax技术,文件上传可以在后台进行,不会阻塞用户界面,提升用户体验。XMLHttpRequest Level 2支持...
1. **文件选择** - 在客户端(例如网页)上,程序可能使用HTML5的`<input type="file">`标签来让用户选择要上传的文件。 2. **文件读取** - 上传程序需要读取用户选择的文件,这在JavaScript中可能使用`FileReader ...