Как скачать файл на сайте wordpress через метод post?

я написал вот такой код для скачивания файлов

<form method="POST">
<input type="submit" value="downlode" name="test_downlode">
</form>
if ($_POST[‘test_downlode’]){
$file = ("http://localhost/wor/wp-content/uploads/2018/12/BI7GI_8-01_IL_01-k1.jpg");
if (file_exists($file)) {
if (ob_get_level()) {
ob_end_clean();
}
header(‘Content-Description: File Transfer’);
header(‘Content-Type: application/octet-stream’);
header(‘Content-Disposition: attachment; filename=’ . basename($file));
header(‘Content-Transfer-Encoding: binary’);
header(‘Expires: 0’);
header(‘Cache-Control: must-revalidate’);
header(‘Pragma: public’);
header(‘Content-Length: ‘ . filesize($file));
readfile($file);
exit;
}}

Но она не работает для ссылок
Есть ли способ с помощью PHP скачать файл из базы данных wordpress?

Anonymous
Отправить
Ответ на: