时间:2021-07-01 10:21:17 帮助过:4人阅读
if ($_server['request_method'] == ‘post’) { //上传请求
$status = apc_fetch(’upload_’ . $_post['apc_upload_progress']);
$status['done'] = 1;
echo json_encode($status); //输出给用户端页面里的ajax调用,相关文档请自己寻找
exit;
} elseif (isset($_get['progress_key'])) { //读取上传进度
$status = apc_fetch(’upload_’.$_get['progress_key']);
echo json_encode($status);
exit;
}
uploadprogress实现方法:
1.使用pecl 安装uploadprogress
2.php.ini里面设置 uploadprogress.file.filename_template = “/tmp/upd_%s.txt”
3.关键代码:
if($_server['request_method']==’post’) {
if (is_uploaded_file($_files['upfile']['tmp_name'])) {
$upload_dir = ‘your_path/’;
$ext = strrchr($_files['video']['name'], ‘.’);
$sessid = $_post['upload_identifier'] ;
$tmpfile = $upload_dir . $sessid;
$sessfile = $upload_dir . $sessid .$ext;
if (move_uploaded_file($_files['upfile']['tmp_name'],$tmpfile)) {
//上传成功
}
}
1 2 3
http://www.bkjia.com/PHPjc/444914.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444914.htmlTechArticle实现篇 一般情况,用php教程实现上传进度条就下面两种方法: 1.apc扩展(作者是php教程的创始人,5.2后php已经加入apc扩展) 2.pecl扩展模块...