N
N
not-deanon2017-08-08 12:44:15
PHP
not-deanon, 2017-08-08 12:44:15

How to download a file in xlsm format from the server?

Hello! I download the file with the following code:

header("Content-Type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=Templ10.xlsm");
echo file_get_contents('uploads/Templ10.xlsm');

But it won't open with the error "The file cannot be opened because the format or extension is invalid." If the same file is downloaded from the server via ftp, then everything works fine.
There is also a problem with encoding. I am trying to download xls file. On the server it contains Russian letters, and after downloading - character sets. Plus all formatting disappears.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Svirsky, 2017-08-08
@e_svirsky

Specify an absolute path. It seems that he stupidly cannot find the file.

A
Andrey Nikolaev, 2017-08-08
@gromdron

Pass it right , don't use file_get_contents.
See 3 approach (at most 2)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question