PHP file download not working in Linux
<p>I am using the below code to download mp3 files from server. The code is working fine in my local system(Windows OS).</p>

<p>However, when I am moving the code to server(Linux), I am getting a file not found error. I am sure that the file paths are correct and file is readable</p>

<pre><code>if ($fd = fopen ($filePath, "r")) {
    $fsize = filesize($filePath);
    $path_parts = pathinfo($filePath);
    $ext = strtolower($path_parts["extension"]);
    switch ($ext) {                 
        case "mp3":                 
        header("Content-type: audio/mpeg"); // add here more headers for diff. extensions
        header("Content-Disposition: attachment; filename=\"".$originalFileName."\""); // use 'attachment' to force a download
        break;
        default;
        header("Content-type: application/octet-stream");
        header("Content-Disposition: filename=\"".$originalFileName."\"");
    }
    header("Content-length: $fsize");
    header("Cache-control: private"); //use this to open files directly
    while(!feof($fd)) {
        $buffer = fread($fd, 2048);
        echo $buffer;
    }
}
fclose ($fd) 
</code></pre>
