я эта проблема не в состоянии загрузить изображение с сервера на ПК (без сохранения строки), сообщение об ошибке не было показаноPHP Загрузка файла с помощью Ajax Проблемы
Выход я получаю некоторые нечитаемый код из хрома Google инспектировать элемент
заранее спасибо
Javascript
function Download(id) {
console.log(id);
$.ajax({
type: 'post',
url: 'DownloadRequest.php',
data: {filename: id.trim()},
});
}
DownloadRequest.php Файл
<?php
$file = $_POST['filename'];
header ("Content-Type: application/download");
header ("Content-Disposition: attachment; filename=$file");
header("Content-Length: " . filesize("$file"));
$fp = fopen("$file", "r");
fpassthru($fp);
?>
Решение
function Download(id) {
window.location="DownloadRequest.php?url="+id.trim();
}
<?php
$file = $_GET['url'];;
header ("Content-Type: application/download");
header ("Content-Disposition: attachment; filename=$file");
header("Content-Length: " . filesize("$file"));
$fp = fopen("$file", "r");
fpassthru($fp);
?>
Посмотреть это сообщение для загрузки с помощью jQuery http://stackoverflow.com/questions/3749231/download-file-using-javascript-jquery – Tristan