我使用以下代码下载文件
#_*_ coding:utf-8 _*_
import re
'''
refer to the code of Gábor Erds below
'''
N = "wherewhere"
cnt = 0
result = ''
countN = 0
showresult = []
for i in range(1,len(N)+1):
if cnt <= len(re.findall(N[0:i],N)):
cnt = len(re.findall(N[0:i],N))
result = re.findall(N[0:i],N)[0]
countN = len(N)/len(result)
for i in range(0,countN):
showresult.append(result)
print showresult
它将使用faullt下载文件,因为我没有解压缩文件。 我将评论下面的一行
$full_path_file=ctrl_options::GetSystemOption('sentora_root') . "etc/tmp/". basename($backup);
$file_for_user=basename($backup);
header('Content-Description: File Transfer');
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="'.$file_for_user.'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($full_path_file));
readfile($full_path_file);
它工作正常。让我知道标题的clearcut功能(&#39; Content-Length:&#39; .cilesize($ full_path_file));?
答案 0 :(得分:0)
我想, 在下载任何文件之前,浏览器应该知道您正在下载的文件大小。浏览器/下载管理器可以管理下载,部分下载数据等