【问题标题】:How to save the .pkpass file in a server directory using php如何使用 php 将 .pkpass 文件保存在服务器目录中
【发布时间】: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


【解决方案1】:

感谢您的回答,但我认为它解释得不好,我只是想将我的文件保存在一个目录中,我意识到在执行我的操作时我正在强制下载文件,我在下面解决了方式,只是删除了标题

if($output == true) {
    $fileName = $this->getName() ? $this->getName() : $name;
    if(!strstr($fileName, '.')) {
        $fileName .= '.pkpass';
    }
    $fileName = 'upload/pkpass/'.$fileName;                   
    $fp = fopen($fileName, 'w');
    fwrite($fp, $file);
    fclose($fp); 
}

问候

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-21
    • 2016-01-22
    • 1970-01-01
    相关资源
    最近更新 更多