当前位置:网站首页>Webuploader file upload drag upload progress monitoring type control upload result monitoring control
Webuploader file upload drag upload progress monitoring type control upload result monitoring control
2022-07-05 19:26:00 【-Geng Rui-】
webuploader Is a very compatible And also very easy to use front-end controls vue It can also be used in projects
Let's take a brief look at
You can download the resource plug-in I uploaded first
https://download.csdn.net/download/weixin_45966674/85899651?spm=1001.2014.3001.5503
After downloading, we can see the following directory
you 're right This plug-in depends on jquery This is a small failure But the technology of the previous generation It is also true that they basically depend on jq
Then we build a directory To build a webuploader Put these four files inside
And then webuploader Peer directory creation page
The demo code is as follows
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- introduce WebUploader File upload CSS-->
<link rel="stylesheet" type="text/css" href="./webuploader/webuploader.css" media="screen" />
<script type="text/javascript" src="./webuploader/jquery-1.8.3.js"></script>
<!-- introduce WebUploader File upload JS-->
<script type="text/javascript" src="./webuploader/webuploader.js"></script>
<style> .maskUpload{
width: 300px; height: 300px; background-color: blueviolet; } </style>
</head>
<body>
<!-- Used to store file information -->
<div class="uploader-demo">
<div class="btns">
<div id="filePicker"> Select File </div>
<button id="ctlBtn" class="mybutton" onclick="upload_imgs()"> Start uploading </button>
<div class = "maskUpload"></div>
</div>
</div>
<script type="text/javascript"> var uploader; $(function(){
// initialization Web Uploader, Each file uploaded will create a uploader object , When multiple files are selected at the same time , Multiple... Will be created uploader object . uploader = WebUploader.create({
// After selecting the file , Whether to upload automatically . auto: false, //true when , Select the file and upload it automatically . // swf File path swf: 'resources/widget/webuploader/Uploader.swf', // File receiving server . server: 'upload/uploadImg', // Select the file button . Optional . pick: '#filePicker', dnd: ".maskUpload", accept: {
title: ' Upload files ', // Supports the types of files uploaded extensions: 'jpg,png,doc,xlsx', mimeTypes: '*' } }); // Triggered when the file is added to the queue uploader.on('fileQueued',function (file) {
console.log(file); }); // Triggered when all files in the queue are uploaded uploader.on('error', (type) => {
console.log(' Triggered when the upload file type is not supported '); }); // The progress is returned in real time during file uploading uploader.on('uploadProgress', (file, percentage) => {
console.log(' Upload progress '+percentage); }); // Triggered when the file is uploaded successfully uploader.on("uploadSuccess",function (file,response) {
console.log(' Upload successful '); }); // Triggered when file upload error uploader.on('uploadError', (file, reason) => {
console.log(' Upload failed '); }); // Triggered when all files in the queue are uploaded uploader.on('uploadFinished', (file, reason) => {
console.log(' End of upload '); }); }) // To upload pictures function upload_imgs() {
if (uploader){
uploader.upload(); } } </script>
</body>
</html>
Then we click upload here extensions Control file suffix format The format I set Only support jpg,png,doc,xlsx
Click upload if it is right Will be added to the queue Trigger fileQueued Each file added to the queue will trigger fileQueued We can define an array take fileQueued Every file stream of is saved for display
Then we upload unsupported formats Will be uploadFinished Stop it
When we click upload, it will trigger uploadProgress This is the biggest highlight of this framework You can monitor the progress of uploading How far is it
perform uploader.upload(); upload
Upload success triggers uploadSuccess
If it fails, execute uploadFinished
Of course, another highlight is drag upload
dnd Attribute control It corresponds to css Selectors Choose which element to drag to trigger upload
We have set up class by maskUpload Of div
When we drag a file directly from the computer to the interface, it will trigger it to be added to the queue It is also very easy to use
But this tool needs background cooperation server Control the service port for uploading swf Set the name of the uploaded interface
边栏推荐
- 【合集- 行业解决方案】如何搭建高性能的数据加速与数据编排平台
- MMO项目学习一:预热
- MMO project learning 1: preheating
- 软件测试工程师是做什么的?待遇前景怎么样?
- Debezium系列之:记录mariadb数据库删除多张临时表debezium解析到的消息以及解决方法
- Pandora IOT development board learning (HAL Library) - Experiment 8 timer interrupt experiment (learning notes)
- Reptile exercises (II)
- 太牛了,看这篇足矣了
- HiEngine:可媲美本地的云原生内存数据库引擎
- 100million single men and women supported an IPO with a valuation of 13billion
猜你喜欢
开源 SPL 消灭数以万计的数据库中间表
数学分析_笔记_第9章:曲线积分与曲面积分
全网最全的低代码/无代码平台盘点:简道云、伙伴云、明道云、轻流、速融云、集简云、Treelab、钉钉·宜搭、腾讯云·微搭、智能云·爱速搭、百数云
CF: B. almost Ternary Matrix [symétrie + règles de recherche + Construction + I am Construction Waste]
司空见惯 - 英雄扫雷鼠
IBM has laid off 40 + year-old employees in a large area. Mastering these ten search skills will improve your work efficiency ten times
Go语言 | 01 WSL+VSCode环境搭建避坑指南
Django使用mysqlclient服务连接并写入数据库的操作过程
14、用户、组和权限(14)
Fuzor 2020 software installation package download and installation tutorial
随机推荐
【obs】QString的UTF-8中文转换到blog打印 UTF-8 char*
数学分析_笔记_第9章:曲线积分与曲面积分
Bitcoinwin (BCW)受邀参加Hanoi Traders Fair 2022
信息/数据
IBM大面积辞退40岁+的员工,掌握这十个搜索技巧让你的工作效率至上提高十倍
C#应用程序界面开发基础——窗体控制(6)——菜单栏、工具栏和状态栏控件
Apprentissage du projet MMO I: préchauffage
面试官:Redis中集合数据类型的内部实现方式是什么?
C# 语言的高级应用
Android面试,android音视频开发
基于FPGA的超声波测距
[Collection - industry solutions] how to build a high-performance data acceleration and data editing platform
JAD的安装、配置及集成IDEA
Fundamentals of shell programming (Chapter 9: loop)
Pandora IOT development board learning (HAL Library) - Experiment 8 timer interrupt experiment (learning notes)
Debezium系列之:解析默认值字符集
HAC集群修改管理员用户密码
redis集群模拟消息队列
Django uses mysqlclient service to connect and write to the database
手机开户选择哪家券商公司比较好哪家平台更安全