关键词:
<!DOCTYPE html>
<html>
<head>
<title>Uploader</title>
<style type="text/css">
*
transition: 0.3s;
body
background: #eaeaea;
text-align: center;
#container
background: white;
box-shadow: 0px 0px 15px black;
border-radius: 0px 0px 4px 4px;
border-top: 3px purple solid;
width: 70%;
margin: 50px auto;
padding: 20px;
text-align: center;
position: relative;
z-index: 2;
.upload-btn
cursor: pointer;
padding: 15px 20px;
background: #297cde;
color: white;
border-radius: 4px;
box-shadow: 0px 0px 5px black;
transition: 0.3s;
position: relative;
z-index: 5;
.upload-btn:hover
background: blue;
input#file
opacity: 0;
position: absolute;
z-index: -1;
#upload
cursor: pointer;
padding: 15px 20px;
background: purple;
color: white;
border-radius: 0px 0px 4px 4px;
box-shadow: 0px 0px 5px black;
transition: 0.3s;
border: 0;
position: relative;
top: -50px;
z-index: 1;
#upload:hover
box-shadow: 0px 0px 15px black;
#progress
position: absolute;
z-index: 3;
top: 0px;
left: 0px;
width: 70%;
background: orange;
opacity: 0.8;
height: 100%;
border-right: 3px red solid;
display: none;
#progress > div
position: relative;
width:100%;
height: 100%;
#progress > div > span
position: absolute;
bottom: 100%;
right: -21px;
width: 40px;
height: 20px;
text-align: center;
vertical-align: middle;
background: red;
font-size: small;
font-weight: bold;
padding-top: 5px;
border-radius: 7px 7px 0px 0px;
#progress > div > span:hover
box-shadow: 0px 0px 5px black;
</style>
</head>
<body>
<div id="container">
<div id="progress"><div><span id="progress-text">50%</span></div></div>
<label for="file" class="upload-btn" id="upload-btn-main">Select file</label>
<input type="file" name="file" id="file">
</div>
<button id="upload" onclick="uploadFile();">Upload!</button>
</body>
<input type="hidden" name="hi" id="hi-him">
<script type="text/javascript">
var url = "/upload.php";
function $(el)
return document.getElementById(el);
$("file").onchange = function(e)
$("upload-btn-main").innerHTML = "Selected file " + $("file").files[0].name + " (size :"+ getSize($("file").files[0].size) + " )";
function getSize(size)
if (size < 1024 * 1024)
return Math.round(size / 1024) + " kb";
else
return Math.round(size / 1024 / 1024) + " mb";
var ajax;
function uploadFile()
if ($("file").files.length == 0)
alert('please select a file');
return;
if (ajax != null)
ajax.abort();
ajax = null;
uploadFinished();
return;
var formData = new FormData();
formData.append("image", $("file").files[0]);
ajax = new XMLHttpRequest();
ajax.onreadystatechange = function()
if (ajax.readyState == 1)
$("upload").innerHTML = "Cancel Upload";
if (ajax.readyState == 4)
if (ajax.status == 200)
uploadCompleted();
else
alert('Error: ' + ajax.statusText);
uploadFinished();
;
ajax.upload.addEventListener('progress', function(e)
window.setTimeout(function()
var pre = Math.ceil(e.loaded/e.total * 100);
$("progress").style.width = pre + '%';
$("progress-text").innerHTML = pre + "%";
, 0);
, false);
ajax.open('POST', url, true);
ajax.send(formData);
initalizeProgress();
function uploadFinished()
$("progress").style.display = "none";
$("upload").innerHTML = "Upload!";
$("file").value = "";
$("upload-btn-main").innerHTML = "Select file";
ajax = null;
function uploadCompleted()
alert('Uploaded!');
function initalizeProgress()
$("progress").style.display = "block";
$("progress-text").innerHTML = "0%";
$("progress").style.width = 0 + '%';
</script>
</html>
[layui]上传文件带进度条+表单提交功能优化(代码片段)
上传文件带进度条+表单提交功能优化前期做了一个简视频提交;每次只提交一个需要重新上传。视频文件较大时候没有进度提示,用户体验并不好,今天做一个简单的优化!如果监听提交表单时候,回调路径可能还未完成。提... 查看详情
jquery上传文件显示进度条(代码片段)
<!DOCTYPEhtml><html><head><metacharset="UTF-8"><scriptsrc="../js/jquery.js"></script></head><body><h2>HTML5异步上传文件,带进度条(jQuery)</h2><formm 查看详情
php使用进度条上传文件-php和jquery(代码片段)
查看详情
layui文件上传进度条(模拟)(代码片段)
1.修改上传组件js(没测)https://blog.csdn.net/weixin_42457316/article/details/81017471https://www.cnblogs.com/youmingkuang/p/9183528.htmlhttps://fly.layui.com/jie/19430/ 1、upload.js扩展功能利用ajax的xhr属性实现该功能修改过 查看详情
异步上传文件(jquery.form)+进度条+上传到ftp服务器(代码片段)
最近写了一个小项目需要上传文件显示进度条到ftp,总结一下分享我用的是jQuery.form.js上传ftp服务器,自己百度去搭建很简单的Talkischeap.Showmeyourcode. GitHub上面的源码:https://github.com/Vinkong/learngitaspx页面<%@PageLan... 查看详情
利用formdata对象+xhr新特性实现文件上传——带进度条(代码片段)
小编今天又get到一个新技能,就是上传图片并显示进度条,话不多说,直接进入正题!冲冲冲!!💪实现效果:当点击上传文件按钮后,如果未选择文件,会跳出请选择要上传的文件提示框... 查看详情
通过 HTTP 表单上传文件,通过 MultipartEntityBuilder,带有进度条
】通过HTTP表单上传文件,通过MultipartEntityBuilder,带有进度条【英文标题】:UploadafilethroughanHTTPform,viaMultipartEntityBuilder,withaprogressbar【发布时间】:2013-09-2815:31:17【问题描述】:短版-org.apache...MultipartEntity已弃用,其升级版Multipart... 查看详情
记录小文件上传的几个例子(含进度条效果,附源码下载)(代码片段)
1、简单原生上传无javascript脚本、无进度条;借助iframe实现post提交后的无刷新效果;jquery插件ajaxFileUpload.js的实现原型。Html代码<formenctype="multipart/form-data"action="UploadFile_1"method="post"target="frameResult"><divclass="ite 查看详情
如何通过 ASP.NET MVC 上传文件并显示进度条?
】如何通过ASP.NETMVC上传文件并显示进度条?【英文标题】:HowcanIuploadafileviaASP.NETMVCandshowaprogressbar?【发布时间】:2010-11-0122:56:22【问题描述】:我希望允许用户在我的ASP.NETMVC应用程序中浏览文件并将其上传到服务器。如果可能... 查看详情
elementel-upload自定义上传显示进度条,多文件上传进度(代码片段)
<template><div><el-uploadclass="upload-demo"ref="upload":multiple="false"action="void":http-request="customUpload":on-remove="handleRemove":on-progress="progressA":file-list="fileList"multiple:auto-upload="true"><el-buttonslot="trigger"size="small"type="primary">选取文件&... 查看详情
通过后处理上传进度
】通过后处理上传进度【英文标题】:uploadprogresswithpostprocessing【发布时间】:2015-02-2517:24:30【问题描述】:我有一个上传表单,用户可以在其中上传文件。上传完成后,对文件进行后处理,有时上传完成后处理需要10-15秒。上... 查看详情
jqueryajax实现上传文件代码,带进度条
原文:jqueryajax实现上传文件代码,带进度条 源代码下载地址:http://www.zuidaima.com/share/1550463291116544.htmajax上传文件代码,带进度条的。首页http://localhost:端口/项目名/common/test.htm上传中标签: jquery ajax 上传 ... 查看详情
我需要知道已经上传了多少字节来更新进度条android(代码片段)
...一刻,我已经可以上传视频了。我需要在上传文件时显示进度条。我有下一个代码使用AsyncTask和HTTP4.1.1库来模拟FORM。classuploadVideoextendsAsyncTask<Void,Void,String>@OverrideprotectedStringdoInBackground(Voi 查看详情
jqueryajax实现上传文件代码,带进度条
原文:jqueryajax实现上传文件代码,带进度条 源代码下载地址:http://www.zuidaima.com/share/1550463291116544.htmajax上传文件代码,带进度条的。首页http://localhost:端口/项目名/common/test.htm上传中标签: jquery ajax 上传 查看详情
oss上传文件进度条展示
...。在此以上传视频为例,自定义监听监听文件上传进度,通过将字节数和总字节数之间比例写入session中返回给前端进行进度展示。 privatestaticStringendpoint="http://oss-cn-beijing.aliyuncs.com";& 查看详情
文件上传和进度条
】文件上传和进度条【英文标题】:Fileuploadandprogessbar【发布时间】:2013-01-2114:01:05【问题描述】:我想在上传文件时根据读取的文件数量显示进度条。我们如何使用JS和Servlet来实现这一点我知道上传我可以使用apachecommonslib,但... 查看详情
如何在ajax文件上传中显示进度条
】如何在ajax文件上传中显示进度条【英文标题】:Howtoshowprogressbarinajaxfileupload【发布时间】:2013-01-2605:22:52【问题描述】:我的代码发布了ajax请求,但没有显示进度条。请帮助更正代码以显示工作进度条。$(document).ready(function()... 查看详情
使用 jQuery 的文件上传进度条
】使用jQuery的文件上传进度条【英文标题】:FileuploadprogressbarwithjQuery【发布时间】:2013-03-0220:39:19【问题描述】:我正在尝试在我的项目中实现AJAX文件上传功能。我为此使用jQuery;我的代码使用AJAX提交数据。我还想实现一个文... 查看详情