我想知道,我怎样才能实现Vcard下载。这是我当前的代码:
$path = "../../media/resources/";
$file = "someName.vcf";
header('Content-Type: text/x-vCard');
header('Content-Disposition: attachment; filename= "'.$file.'"');
header('Content-Length: '.filesize($path.$file));
header('Connection: close');
readfile($path.$file);不幸的是,它只给出了.vcf文件的内容。如何将这张电子名片作为下载赠送给用户?
发布于 2010-12-16 23:02:35
你有header('Connection: close');,我想它会在读取文件内容之前关闭连接。我已经删除了这条线。
我不确定内容类型是否区分大小写,所以我将其更改为x-vcard,并将content-disposition更改为inline (IE下载问题的已知修复程序)。试试这个:
$path = "../../media/resources/";
$file = "Toni_Junas.vcf";
header('Content-Type: text/x-vcard');
header('Content-Disposition: inline; filename= "'.$file.'"');
header('Content-Length: '.filesize($path.$file));
readfile($path.$file);另外,确保目录"resources“是可读的(目录中的chmod 755 ),并且文件存在……
发布于 2010-12-16 22:54:17
put exit()
readfile($path.$file);
exit();https://stackoverflow.com/questions/4461968
复制相似问题