LINUX.ORG.RU

Закройте доступ к директории при помощи .htaccess, и отдавайте файлы при помощи обычного php. Не забудьте только добавить нужные заголовки с именем файла, размером и типом контента. Есть и другой вариант, связанный с использованием куки. Благодаря ему, сервер может отдавать файлы только клиенту, у которого прописана определённая кука. И выдавать 404 в других случаях. Как это делается, можно прочитать в документации к apache.

lucentcode ★★★★★
()
Последнее исправление: lucentcode (всего исправлений: 1)
Ответ на: комментарий от linuxnewb

А разве по твоей ссылке не то же самое?

Прочитай внимательнее то, что по моей ссылке.

Цитата №1:

$content=file_get_contents($file);
//.. send appropriate headers
header(«Content-type: application/octet-stream»);
header('Content-Disposition: attachment; filename=«' . basename($file) . '»');
header(«Content-Length: ». filesize($file));
echo $content;

...

Is something wrong with this?

This means that our script has to read the file from the disk, which goes through the output buffer, is flushed to the web server and processed before sent to the client.

Цитата №2:

Ideal solution

...

Meet the X-Sendfile

X-Sendfile is a feature that allows a web application to redirect the request for a file to the web server that in turn processes the request, this way eliminating the need to perform tasks like reading the file and sending it to the user.

...

sendfile directive - web server application using it
--------------------- -------------------------------
X-Sendfile - Apache, Lighttpd v1.5, Cherokee
X-LIGHTTPD-send-file - Lighttpd v1.4
X-Accel-Redirect - Nginx, Cherokee

resurtm ★★★
()
Последнее исправление: resurtm (всего исправлений: 2)
Ответ на: комментарий от hidden_4003

Из первого комментария.

Комментарии не читал.

VirRaa ★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.