Как скачать файл используя php скрипт?

Я пытаюсь запустить php-скрипт для загрузки файлов из папки пользователя, передав путь к файлу php-скрипта, и я вижу, что он получает файл, но не скачивает.

<?php
set_time_limit(0);
$destino = 'uploads/'.$_GET['fd'].'/';
//this is where the file is

$arquivo ='teste.txt';//this is the test file to download

$arquivo = filter_var($arquivo, FILTER_SANITIZE_STRING);

$arquivo = basename($arquivo);

$caminho_download = $destino .$arquivo;

if (!file_exists($caminho_download))
die('there is no file');
header('Content-type: octet/stream');
header('Content-disposition: attachment; filename="'.$arquivo.'";');
header('Content-Length: '.filesize($caminho_download));
readfile($arquivo);

?>

когда я проверил браузер в сети, он возвратил это в предварительном просмотре: PGJyIC8 + Cjxi

и это в шапке:

введите описание изображения здесь

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector