当前位置:网站首页>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
边栏推荐
- How MySQL queries and modifies JSON data
- HiEngine:可媲美本地的云原生内存数据库引擎
- 数据库 逻辑处理功能
- 【合集- 行业解决方案】如何搭建高性能的数据加速与数据编排平台
- MySQL中字段类型为longtext的值导出后显示二进制串方式
- Talking about fake demand from takeout order
- 软件测试工程师是做什么的?待遇前景怎么样?
- 数学分析_笔记_第9章:曲线积分与曲面积分
- What does software testing do? What are the requirements for learning?
- Fundamentals of machine learning (III) -- KNN / naive Bayes / cross validation / grid search
猜你喜欢
#夏日挑战赛#数据库学霸笔记,考试/面试快速复习~
四万字长文说operator new & operator delete
5 years of experience, 27 days of Android programmer interview, 2022 programmer advanced classic
微波雷达感应模块技术,实时智能检测人体存在,静止微小动静感知
aggregate
IBM大面积辞退40岁+的员工,掌握这十个搜索技巧让你的工作效率至上提高十倍
HiEngine:可媲美本地的云原生内存数据库引擎
软件测试是干什么的?学习有啥要求?
强化学习-学习笔记4 | Actor-Critic
Reinforcement learning - learning notes 4 | actor critical
随机推荐
基于FPGA的超声波测距
Go语言学习教程(十六)
cf:B. Almost Ternary Matrix【對稱 + 找規律 + 構造 + 我是構造垃圾】
司空见惯 - 英雄扫雷鼠
测试外包公司怎么样?
测试的核心价值到底是什么?
word如何转换成pdf?word转pdf简单的方法分享!
redis集群模拟消息队列
爬虫练习题(二)
Microwave radar induction module technology, real-time intelligent detection of human existence, static micro motion and static perception
14、用户、组和权限(14)
完爆面试官,一线互联网企业高级Android工程师面试题大全
Mysql如何对json数据进行查询及修改
Fundamentals of shell programming (Chapter 9: loop)
Debezium系列之:解析默认值字符集
数据库 逻辑处理功能
Decision tree and random forest
国海证券在网上开户安全吗?
vagrant2.2.6支持virtualbox6.1版本
XaaS 陷阱:万物皆服务(可能)并不是IT真正需要的东西