动态创建和下载文档文件 [英] Dynamically Create and Download Doc File

查看:82
本文介绍了动态创建和下载文档文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我试图动态创建.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文件中完成所有操作(创建一个doc文件并让用户下载)?

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?

推荐答案

发现要制作Word文档的标题。第一组用于通用流下载。

You only need the "headers found to make a word document." The first set are for a generic streaming download.

这篇关于动态创建和下载文档文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆