I'm not sure if my code is correct, but I keep on getting an error saying the post
is not allowed in the debugger.
I'm trying to send my javascript variables - the download url & new file name - to my php file and with php then download the .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;
}
?>