【发布时间】:2019-09-11 19:44:31
【问题描述】:
我正在使用 php .pkpass 库,文件生成正确,但它是直接在 Windows 下载中下载的,我希望将其保存在我的应用程序的文件夹中,例如 /upload/
类带来了这个结构
// Output pass
if($output == true) {
$fileName = $this->getName() ? $this->getName() : $name;
if(!strstr($fileName, '.')) {
$fileName .= '.pkpass';
}
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.apple.pkpass');
header('Content-Disposition: attachment; filename="' . $fileName . '"');
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s T'));
header('Pragma: public');
header('Content-Length: ' . $size);
@ob_end_flush();
set_time_limit(0);
echo $file;
return true;
}
我正在尝试类似的方法,但没有成功。请帮帮我
<?php
$filename = 'upload/file.pkpass';
# Download the File
$handle = fopen($filename, "w");
fwrite($handle, $ics_data);
fclose($handle);
header('Pragma: no-cache');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment;filename='.$filename);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
readfile($filename);
exit();
?>
【问题讨论】:
-
这与您如何发送捆绑包无关,更重要的是您的应用程序如何请求它。您的 Windows 应用程序如何请求通行证?
标签: php jquery download passbook