Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在浏览器中显示剩余下载时间和总文件大小?_Php_File_Download_Readfile_Filesize - Fatal编程技术网

Php 如何在浏览器中显示剩余下载时间和总文件大小?

Php 如何在浏览器中显示剩余下载时间和总文件大小?,php,file,download,readfile,filesize,Php,File,Download,Readfile,Filesize,我有以下代码: $file="http://domain/path/file.flv?hash=hashcode"; header('Content-Type: video/x-flv'); header('Content-Disposition: attachment; filename=myvideo.flv' ); readfile($file); 当我访问download.php时,它开始下载,并在浏览器中显示: 1KB,2KB。。。1MB,2MB 我想知道的是如何在下载文件时在

我有以下代码:

$file="http://domain/path/file.flv?hash=hashcode";

header('Content-Type: video/x-flv');

header('Content-Disposition: attachment; filename=myvideo.flv' );

readfile($file);
当我访问download.php时,它开始下载,并在浏览器中显示:

1KB,2KB。。。1MB,2MB

我想知道的是如何在下载文件时在浏览器中显示以下文本,类似这样:

2MB/29MB剩余5分钟

我的意思是,在浏览器的底部(文件下载的地方)——Chrome,或者在“下载”窗口——Firefox

我试着这样做:

header('Content-Length: ' . filesize($file));

但它不起作用。

如果我理解正确,您希望控制浏览器显示上载过程的方式,但遗憾的是您无法做到这一点


您可以使用上传库来完成这项工作,在那里您可以控制上传的外观。

不,这不是我想要的。所以,我想从一个url中获取正确大小的文件,比如:下面是我确信的答案,它将帮助您。