<?php session_start(); ?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>Demo : PHP(5.4) Upload Progress via Session</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="author" content="">
<meta name="robots" content="INDEX,FOLLOW" /> <link rel="shortcut icon" href="/favicon.ico">
<link href="../assets/css/bootstrap.min.css" rel="stylesheet">
<link href="../assets/css/pureweber.css" rel="stylesheet"> <style type="text/css">
.progress{
width:100%;
border:1px solid #4da8fe;
border-radius:40px;
height:20px;
position:relative;
}
.progress .label{
position:relative;
text-align:center;
}
.progress .bar{
position:absolute;
left:0;top:0;
background:#4D90FE;
height:20px;
border-radius:40px;
min-width:20px;
}
</style> </head>
<body>
<div id="nav" class="container">
<div class="inner">
<a href="/" class="logo">PureWeber</a>
<ul>
<li><a id="to-top" href="#nav">&laquo; 回到文章</a></li>
</ul>
</div>
</div>
<div id="wrap" class="container"> <div id="header">
<h1>Demo : PHP(5.4) Upload Progress via Session</h1>
</div>
<div id="article"> <form id="upload-form" action="upload.php" method="POST" enctype="multipart/form-data" style="margin:15px 0" target="hidden_iframe">
<input type="hidden" name="<?php echo ini_get("session.upload_progress.name"); ?>" value="test" />
<p><input type="file" name="file1" /></p>
<p><input type="submit" value="Upload" /></p>
</form> <div id="progress" class="progress" style="margin-bottom:15px;display:none;">
<div class="bar" style="width:0%;"></div>
<div class="label">0%</div>
</div> </div> <!-- #article --> <div id="footer">
<p>Copyright &copy; 2012 PureWeber.com</p>
</div>
</div><!-- #wrap --> <iframe id="hidden_iframe" name="hidden_iframe" src="about:blank" style="display:none;"></iframe>
<script src="../../../jquery-1.11.2.min.js"></script>
<script type="text/javascript">
function fetch_progress(){
$.get('progress.php',{ '<?php echo ini_get("session.upload_progress.name"); ?>' : 'test'}, function(data){
var progress = parseInt(data); $('#progress .label').html(progress + '%');
$('#progress .bar').css('width', progress + '%'); if(progress < 100){
setTimeout('fetch_progress()', 1000);
}else{
$('#progress .label').html('完成!');
}
}, 'html');
} $('#upload-form').submit(function(){
$('#progress').show();
setTimeout('fetch_progress()', 1000);
});
</script>
</body>
</html>
<?php
session_start(); $i = ini_get('session.upload_progress.name'); $key = ini_get("session.upload_progress.prefix") . $_GET[$i]; if (!empty($_SESSION[$key])) {
$current = $_SESSION[$key]["bytes_processed"];
$total = $_SESSION[$key]["content_length"];
echo $current < $total ? ceil($current / $total * 100) : 100;
}else{
echo 100;
} ?>
<?php

if(is_uploaded_file($_FILES['file1']['tmp_name'])){
//unlink($_FILES['file1']['tmp_name']);
move_uploaded_file($_FILES['file1']['tmp_name'], "./{$_FILES['file1']['name']}");
} ?>

php文件上传进度条例子的更多相关文章

  1. HTML5矢量实现文件上传进度条

    在HTML中,在文件上传的过程中,很多情况都是没有任何的提示,这在体验上很不好,用户都不知道到时有没有在上传.上传成功了没有,所以今天给大家介绍的内容是通过HT for Web矢量来实现HTML5文件 ...

  2. 基于HT for Web矢量实现HTML5文件上传进度条

    在HTML中,在文件上传的过程中,很多情况都是没有任何的提示,这在体验上很不好,用户都不知道到时有没有在上传.上传成功了没有,所以今天给大家介绍的内容是通过HT for Web矢量来实现HTML5文件 ...

  3. PHP中使用Session配合Javascript实现文件上传进度条功能

    Web应用中常需要提供文件上传的功能.典型的场景包括用户头像上传.相册图片上传等.当需要上传的文件比较大的时候,提供一个显示上传进度的进度条就很有必要了. 在PHP .4以前,实现这样的进度条并不容易 ...

  4. iOS_文件上传进度条的实现思路-AFNettworking

    iOS_文件上传进度条的实现思路-AFNettworking //要上传的文件名,在这里我使用当前日期做为文件的名称 NSString * fileName =[NSString stringWith ...

  5. asp.net文件上传进度条研究

    文章:asp.net 文件上传进度条实现代码

  6. Layui多文件上传进度条

    Layui原生upload模块不支持文件上传进度条显示,百度,谷歌找了一下不太适用.后面找到一个别人修改好的JS,替换上去,修改一下页面显示即可使用,一下是部分代码 HTML: <div cla ...

  7. spring定时任务-文件上传进度条

    spring定时任务 导依赖 <!-- https://mvnrepository.com/artifact/org.quartz-scheduler/quartz --> <dep ...

  8. 利用Bootstrap简单实现一个文件上传进度条

    © 版权声明:本文为博主原创文章,转载请注明出处 说明: 1. 使用commons-fileupload.jar实现文件上传及进度监听 2. 使用bootstrap的进度条进行页面显示 3. 因为进度 ...

  9. vue多文件上传进度条 进度不更新问题

    转自 hhttp://www.cnblogs.com/muge10/p/6767493.html 感谢这位兄弟的文章,之前因为这个问题 ,我连续在sgmentflow上提问过多次,完全没人能回答.谢谢 ...

随机推荐

  1. 关于mysql安全

    修改root用户密码: update mysql.user set password=password('new_passwd') where user='root'; flush privilege ...

  2. Python中sorted()方法

    Python中sorted()方法的用法 1.先说一下iterable,中文意思是迭代器. Python的帮助文档中对iterable的解释是:iteralbe指的是能够一次返回它的一个成员的对象.i ...

  3. Python tab键自动补齐

    1.进入root家目录  建立.tab文件 .tab文件内容如下: ############################################## import sys import r ...

  4. jsoup解析HTML

    Connection conn = Jsoup.connect(String url); conn.data("txtBill", key);// 设置关键字查询字段 Docume ...

  5. Wilson定理证明

    Wilson定理证明 就是那个\((p-1)! \equiv -1 \pmod{p}\),\(p\)是一个素数. Lemma A \(\mathbb{Z}_p\)可以去掉一个零元变成一个群. 即\(\ ...

  6. Xcode开发技巧之Code Snippets Library

    http://blog.csdn.net/lin1986lin/article/details/21180007 目录(?)[-] 引言 什么是Code Snippets 如何新建Code Snipp ...

  7. IntelliJ IDEA 导入web项目的一些配置

  8. 《Head First Servlet JSP》学习笔记

  9. java web 学习 --第十一天(Java三级考试)

    第十天的学习内容:http://www.cnblogs.com/tobecrazy/p/3473954.html Servlet理论知识: 1.servlet 生成class位置 tomcat编译后生 ...

  10. How to call getClass() from a static method in Java?

    刚才在学习Java 使用properties类,遇到这样的错误: Cannot make a static reference to the non-static method getClass() ...