惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google Online Security Blog
Google Online Security Blog
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
V
V2EX
雷峰网
雷峰网
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
F
Full Disclosure
Y
Y Combinator Blog
V
V2EX - 技术
Attack and Defense Labs
Attack and Defense Labs
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
SecWiki News
SecWiki News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
量子位
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AWS News Blog
AWS News Blog
Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
K
Kaspersky official blog
B
Blog
A
Arctic Wolf
Hacker News: Ask HN
Hacker News: Ask HN
L
LangChain Blog
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
Recent Announcements
Recent Announcements
宝玉的分享
宝玉的分享
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
Lohrmann on Cybersecurity
D
Docker
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
The Last Watchdog
The Last Watchdog
S
Security Affairs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy International News Feed
Simon Willison's Weblog
Simon Willison's Weblog

博客园 - mengfanrong

防止WordPress利用xmlrpc.php进行暴力破解以及DDoS 汇编语言学习笔记(5)——[bx]和loop 机房收费系统——项目开发计划书 jquery实现返回基部案例效果 【LeetCode】Power of Two 用C/C++实现对STORM的执行信息查看和控制 bash可改动的环境变量 博主-橄榄山软件创始人-其人其事 构造函数模式自己定义js对象 UVA1626 - Brackets sequence(区间DP--括号匹配+递归打印) CentOS安装NodeJS及Express开发框架 C# 中堆与栈的浅记 RabbitMQ学习笔记 【数据库摘要】10_Sql_Create_Index win10 + VS2010 + OpenCV2.4.10重编译OpenCV开发环境搭建 再看《阿甘正传》 Swift开发iOS项目实战视频教程(二)---图片与动画 360面试小结 System.ServiceModel.CommunicationException: 接收HTTP 响应时错误发生
jQuery上传文件
mengfanrong · 2016-04-22 · via 博客园 - mengfanrong

1.引入资源

<script src="/yami/backend/backres/js/jquery.min.js"></script>
<script src="/yami/backend/backres/js/jquery.ui.widget.js"></script>
<script src="/yami/backend/backres/js/jquery.iframe-transport.js"></script>
<script src="/yami/backend/backres/js/jquery.fileupload.js"></script>

2.在form中加入
<input type="file" name="excel" id="fileupload" style="display:none" onclick="upload()" multiple/>
<a href='' onclick="document.getElementById('fileupload').click();return false;">
    <div class="batch">批量导入用户手机号</div>
</a>

点击a标签触发<input>点击事件
 //选择文件后自己主动上传
    function upload() {
        $('#fileupload').fileupload({
            url: "/yami/backend/coupon.getPhonesFromExcel.do",
            dataType: 'json',
            add: function (e, data) {
                var goUpload = true;
                var uploadFile = data.files[0];
                if (!(/\.(xls||xlsx)$/i).test(uploadFile.name)) {
                    alert('请选择excel文件!');
                    goUpload = false;
                }
                if (uploadFile.size > 2000000) { // 2mb
                    alert('上传文件大小不得超过2M');
                    goUpload = false;
                }
                if (goUpload == true) {
                    data.submit();
                }
            },
            done: function (e, data) {
                document.getElementById("showPhones").innerHTML = "<p>成功上传" + data.result.length + "手机号!!!</p>";
                document.getElementById("phoneList").setAttribute("value", data.result);
            }
        });
    }