質問

知りたいのですが、どうすれば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ファイルからコンテンツのみを提供します。ダウンロードとしてこのVCardをユーザーに渡すにはどうすればよいですか?

役に立ちましたか?

解決

あなたが持っている header('Connection: close'); ファイルの内容が読み取られる前に、接続を閉じると想像します。ラインを削除しました。

コンテンツタイプの症例感度がわからないので、X-Vcardに変更し、コンテンツ偏見をインラインに変更しました(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);

また、ディレクトリの「リソース」が読み取り可能であることを確認し、ファイルが存在することを確認してください...

他のヒント

置く exit()

readfile($path.$file);
exit();
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top