1

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;
    }
?>
HovyTech
  • 299
  • 5
  • 19

1 Answers1

1

That link you're posting to isn't executed. I went to it and it downloaded the php source code. According to this answer, github pages doesn't execute server-side code (php), its just for static content (html,css,js,etc)

Community
  • 1
  • 1
Ben Lorantfy
  • 963
  • 1
  • 7
  • 19