1
我不确定我的代码是否正确,但我一直收到一个错误,说明调试器中不允许使用post
。jQuery发布变量到php并下载文件
我试图发送我的JavaScript变量 - 下载URL &新的文件名 - 到我的PHP文件和PHP然后下载.mp3。
的jQuery:
$.post('https://scriptkitti.github.io/Articles/Files/DownCloud.php', {
'filePath': url + '?client_id=' + client,
'fileTitle': title
});
PHP:
<?php
if (isset($_POST['fileTitle'], $_POST['filePath'])) {
$fileTitle = $_POST['fileTitle'];
$filePath = $_POST['filePath'];
header('Content-Type: audio/mp3');
header('Content-Disposition: attachment; filename="' . $fileTitle . '.mp3";');
header('Pragma: public');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Length: ' . filesize($filePath));
readfile($filePath);
exit;
}
?>
这将解释许多事情。谢谢! – HovyTech