文件上传按钮(适配所有浏览器)
来源:互联网 发布:百度软件开发笔试 编辑:程序博客网 时间:2024/06/04 20:18
1、需要引用bootstrap
<form id="file_upload" action="__APP__/File/upload" method="post" enctype="multipart/form-data"> <span class="btn btn-success" onclick="$('#fileInput').trigger('click');">上传文件</span> <span style="display: none;"> <input type="file" name="upload_file" id="fileInput" onchange='$("#uploadForm").submit();'/> </span></form>
2、正常使用<
html
xmlns="http://www.w3.org/1999/xhtml">
<
head
>
<
style
type="text/css">
*,body{margin:0px;padding:0;}
#input-file {
margin:100px;
position: relative; /* 保证子元素的定位 */
width: 110px;
background: #eee;
border: 1px solid #ddd;
text-align: center;
cursor: pointer;
box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.2);
}
#text {
height: 27px;
line-height:25px;
cursor:pointer;
width:108px;
border:none;
display: inline-block;
color: #666;
font-family: 微软雅黑;
font-size: 15px;
font-weight:bold;
}
#file {
display:none;
position: absolute;
top: 0;
left: 0;
width: 110px; /* 宽高和外围元素保持一致 */
height: 26px;
opacity: 0;
-moz-opacity: 0; /* 兼容老式浏览器 */
filter: alpha(opacity=0); /* 兼容IE */
}
</
style
>
</
head
>
<
body
>
<
div
id="input-file">
<
input
id="file" type="file" />
<
input
type="button" onclick="file.click()" id="text" value="点击上传">
</
div
>
</
body
>
</
html
>
阅读全文
0 0
- 文件上传按钮(适配所有浏览器)
- 【js】弹出文件选择框,可用与文件上传(适配所有浏览器)
- 【js】弹出文件选择框,可用与文件上传(适配所有浏览器)
- file上传按钮替换以及解决IE浏览器隐藏file按钮不能上传文件问题
- 自定义文件上传按钮
- 按钮上传文件js
- JavaScript 图片的上传前预览(兼容所有浏览器)
- js 图片的上传前预览上传的图片(兼容所有浏览器)
- 修改上传文件按钮值
- input上传文件按钮使用
- 点击按钮实现文件上传
- [html]自定义文件上传按钮
- 修改文件上传按钮样式
- 美化input文件上传按钮
- 自定义文件上传按钮样式
- 【CSS】自定义上传文件按钮
- 自定义 文件上传按钮样式
- uploadify点击按钮上传文件
- calendarview 日历控件
- 浅谈SAP CRM开发——技术概念、与ECC 系列产品区别
- Asp.Net Core-Authorize 特性
- 线程的随机性之实现Thread类
- Spire.Doc 教程:在word文档中创建书签
- 文件上传按钮(适配所有浏览器)
- 第六十篇:commons-beanutils使用介绍
- fragmentTabHost中点击一个fragment中的按钮,跳转到另外一个fragment的解决办法
- hibernate 5 与 mysql 5.7 以上 版本的 坑
- Sklearn包含的常用算法
- 计算机网络笔记整理(一):概述
- Asp.Net Core-Identity 配置
- STM32CubeMX介绍、下载与安装
- k:特殊的线性表—栈