vue通过input选取apk文件上传,显示进度条
<template>
<div class="">
<form action="" method="post" class="upload" ref="upload">
<button class="sign" id="uploadFile">选择文件</button>
<input
type="file"
accept=".ipa,.apk"
name="upload"
id="file"
@change="fileSelect($event)"/>
</form>
<button type="button" class="btn" id="upfile" @click="submit" v-if="!isSave">
</div>
</template>
<script>
export default {
name: "",
components:{
},
data(){
return{
percent:0
}
},
created:function(){},
methods:{
//选择文件
fileSelect(e) {
this.files = e.target.files[0];
if(this.files){
this.getMsg();
}
},
//解析安装包
getMsg() {
const parser = new AppInfoParser(this.files).parse().then(result => {
let fileName = this.files.name;
let suffix = fileName.substring(fileName.lastIndexOf(".") + 1,fileName.length);
if (result) {
this.icon = result.icon;
if (suffix == 'ipa') {
if (result.CFBundleDisplayName == undefined) {
this.appname = result.CFBundleName;
} else {
this.appname = result.CFBundleDisplayName;
}
this.apppackage = result.CFBundleIdentifier;
this.appTeamName = result.mobileProvision.TeamName;
this.appversion = result.CFBundleShortVersionString var str = result.mobileProvision.ProvisionsAllDevices;
var test_v = result.mobileProvision.ProvisionedDevices;
if (str) {
this.apptype = "企业版";
} else {
if (result.mobileProvision.DeveloperCertificates.length >= 0) {
this.apptype = '测试版本';
} else {
this.apptype = "未签名应用" ;
}
}
this.isShow = true;
return;
}
if (suffix == 'apk') {
this.appname = result.application.label[0];
this.apppackage = result.package;
this.appversion = result.versionCode;
}
this.isShow = true;
}
})
},
// 上传apk文件
submit(){
let that = this
// 获取表单对象上传apk文件
var fm = this.$refs.upload;
// 实例化FormData对象
var fd = new FormData();
//添加上传的文件以及token参数
fd.append('token',this.token)
fd.append('file',document.querySelector('input[type=file]').files[0])
// 创建XMLHttpRequest对象
var xhr = new XMLHttpRequest();
// 调用open方法准备ajax请求
xhr.open('post','http://xx.xxxx.cn/api/user/upload/xxx');
var jdt = this.$refs.progressbar;
// 绑定onprogress事件可获取上传的进度
xhr.upload.onprogress = function(evt){
let percent = (evt.loaded / evt.total).toFixed(2);
that.percent = parseInt(percent*100)
console.log(that.percent)
}
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
let data = JSON.parse(xhr.responseText) //转化为对象便于操作
console.log(data)
}
}
// 发送ajax请求
xhr.send(fd);
},
},
mounted:function(){}
}
</script>
<style scoped> </style>
vue通过input选取apk文件上传,显示进度条的更多相关文章
- vue+element UI + axios封装文件上传及进度条组件
1.前言 之前在做项目的时候,需要实现一个文件上传组件并且需要有文件上传进度条,现将之前的实现过程简单记录一下,希望可以帮助到有需要的人. 项目用的是Vue框架,UI库使用的是element UI,前 ...
- atitit.文件上传带进度条的实现原理and组件选型and最佳实践总结O7
atitit.文件上传带进度条的实现原理and组件选型and最佳实践总结O7 1. 实现原理 1 2. 大的文件上传原理::使用applet 1 3. 新的bp 2 1. 性能提升---分割小文件上传 ...
- atitit. 文件上传带进度条 atiUP 设计 java c# php
atitit. 文件上传带进度条 atiUP 设计 java c# php 1. 设计要求 1 2. 原理and 架构 1 3. ui 2 4. spring mvc 2 5. springMVC.x ...
- Jquery.Uploadify实现批量上传显示进度条 取消 上传后缩略图显示 可删除
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UpLoad.aspx.cs&q ...
- springMVC+ajax 文件上传 带进度条
前端代码: <form id= "uploadForm"> <p >指定文件名: <input type="text" name= ...
- struts2多文件上传(带进度条)demo+说明
利用plupload插件实现多文件上传,实现图片: 在jsp写入js代码: z<%@ page language="java" contentType="text/ ...
- BootStrap Progressbar 实现大文件上传的进度条
1.首先实现大文件上传,如果是几兆或者几十兆的文件就用基本的上传方式就可以了,但是如果是大文件上传的话最好是用分片上传的方式.我这里主要是使用在客户端进行分片读取到服务器段,然后保存,到了服务器段读取 ...
- HTML5文件上传还有进度条
以下是自学it网--中级班上课笔记 网址:www.zixue.it 需要在chrome,ff,IE10下运行 html页面 <!DOCTYPE html> <html lang=&q ...
- js 文件异步上传 显示进度条 显示上传速度 预览文件
通常文件异步提交有几个关键 1.支持拖拽放入文件.2.限制文件格式.3.预览图片文件.4.上传进度,速度等,上传途中取消上传.5.数据与文件同时上传 现在开始笔记: 需要一个最基础的元素<inp ...
- Springboot 文件上传(带进度条)
1. 相关依赖 pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http ...
随机推荐
- Twitter的分布式自增ID算法snowflake(雪花算法) C#和Java版
概述 分布式系统中,有一些需要使用全局唯一ID的场景,这种时候为了防止ID冲突可以使用36位的UUID, 但是UUID有一些缺点,首先他相对比较长,另外UUID一般是无序的. 有些时候我们希望能使用一 ...
- springBoot打war包部署tomcat
1.修改maven的pom.xml文件 <packaging>war</packaging> 2.排除springboot内嵌的tomcat <dependency> ...
- mysql---插入日期类型的数据并把其设置为主键
Python日期格式化方法 import datetime datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") dt=dat ...
- #主席树,Dijkstra,哈希#CF464E The Classic Problem
题目 边权均为2的幂次的无向图,求 \(S\) 到 \(T\) 的最短路 \(n,m\leq 10^5\) 分析 最短路直接考虑用 Dijkstra,它需要维护松弛操作和堆, 那么也就是要重载加号和小 ...
- #莫比乌斯反演,期望#CF1139D Steps to One
题目 每次随机选一个 \(1\) 到 \(m\) 之间的数加在数列末尾, 数列中所有数的 \(\gcd=1\) 时停止,求数列期望长度.\(m\leq 10^5\) 分析 求期望长度的一种方法就是枚举 ...
- 劫持TLS绕过canary pwn89
劫持TLS绕过canary pwn88 首先了解一下这个东西的前提条件和原理 前提: 溢出字节够大,通常至少一个page(4K) 创建一个线程,在线程内栈溢出 原理: 在开启canary的情况下,当程 ...
- SQLAlchemy详解
一.SQLAlchemy介绍 SQLAlchemy 是 Python SQL 工具包和对象关系映射器,为应用程序开发人员提供 SQL 的全部功能和灵活性. SQLAlchemy支持SQLite.Pos ...
- Gitee码云:用git上传本地文件到码云gitee的方法
首先登录码云 https://gitee.com/,注册一个账号,并登录账号. 1. 在码云上创建项目 在码云首页顶部,下图所示,右上角头像旁边的加号,鼠标移上去会显示下拉的,点击"新建项目 ...
- (数据科学学习手札159)使用ruff对Python代码进行自动美化
本文示例代码已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 大家好我是费老师,在日常编写Python代码的过 ...
- 前端使用 Konva 实现可视化设计器(4)
给上一章做一个补充,就是实现通过上下左右按键移动所选节点. 继续求 Star ,希望大家多多一键三连,十分感谢大家的支持~ 创作不易,Star 50 个,创作加速! github源码 gitee源码 ...