Jump to content

Recommended Posts

Hi,

 

I have a word document in a non-root folder and I wrote a code that allows users to download the file. Code is

 

rename ("../cgifolder/docxfile.docx","docx/docxfile.docx");

header("Content-disposition: attachment; filename=docxfile.docx");
header('Content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
readfile("docx/docxfile.docx");

 

I have two questions ...

 

1. I am seeing that downloaded content a corrupt file while file on server is MS2010 readable. What is wrong with my code?

2. Can I place files in cgi without renaming it to move to root folder and still allow users to download the file

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/268949-php-force-docx-downloads/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.