Force download with Header does not work in PHP

Asked

Viewed 58 times

1

I use this code to force download, it works perfect when I run it on XAMPP, however it returns corrupted file when running on ubuntu, what can I do to fix?

        header('Content-Length: ' . filesizecurl($file_path));
        header('Content-Type: "application/zip"');
        header('Content-Disposition: attachment; filename="'.basename($new_name).'"');
        header("Content-Transfer-Encoding: binary");
        header('Expires: 0');
        header('Pragma: no-cache');
        // Envia o arquivo para o cliente
        readfile($file_path);
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.