B
B
bozilly2015-08-19 19:52:36
PHP
bozilly, 2015-08-19 19:52:36

What should be in the headings?

What should be written in the headings so that when you go to the page it is downloaded?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stalker_RED, 2015-08-19
@bozilly

header('Content-Type: application/octet-stream'); // или какой там у вас mime-type
header('Content-Transfer-Encoding: Binary'); // или текст?
header('Content-disposition: attachment; filename="file.exe"');

Еще неплохо бы указать header('Content-Length: '.filesize($fn));
Но он не всегда известен заранее, и иногда работает без него.

Котик Антон, 2015-08-19
@27cm

Отдаем файлы эффективно с помощью PHP

Олег Красавин, 2015-08-19
@okwinza

header("Content-Type: audio/mpeg");
header('Content-Length: ' . filesize($track));
header('Content-Disposition: attachment; filename="test.mp3"');
$str = "/home/user/gets/".$track;
readfile($str); 
exit;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question