PHP动态创建和下载文件文件 [英] PHP Dynamically Create and Download Doc File
问题描述
所以我试图动态创建一个.doc文件,并让用户点击一个按钮时下载。
So I'm trying to both dynamically create a .doc file and have the user download it when he clicks a button.
这些是我发现的标题下载文件
These are the headers i found to download a file
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
这些都是我找到的头文件。
And these are the headers i found to make a a word document
header('Content-type: application/vnd.ms-word');
header('Content-Disposition: attachment; Filename='.$myFile);
我只是很难将图片整合在一起,因为他们的任务都有一个内容-Type'标题。我先创建文件,保存,然后下载?或者我可以在一个php文件中做所有的(创建一个文档文件并将其下载)
I'm just having a hard time just fitting the picture together because they both tasks have a 'Content-Type' header. Do i create the file first, save it, then download it? Or can i do it all (create a doc file and have user download it) in one php file?
推荐答案
你只需要发现头文字。第一组是通用的流式下载。
You only need the "headers found to make a word document." The first set are for a generic streaming download.
这篇关于PHP动态创建和下载文件文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!