Minimal script--still getting Cannot modify header

2019-08-25 01:34发布

This question already has an answer here:

This is driving me crazy. It seems like a simple error--I've seen dozens of posts about their scripts are way more complicated then mine.

I have a php script which should force a download by setting the headers. I've slimmed the script down to this:

<?php
header("Content-Type: audio/mp3");
header("Content-Disposition: attachment; filename=\"audio.mp3\";" );
readfile("audio.mp3");
exit();
?>

Why are my headers getting sent out? I tried obj_start and obj_flush, but so far no luck. Could this be a problem with my host? I'm using 1and1.com

1条回答
Deceive 欺骗
2楼-- · 2019-08-25 02:13

Your script works fine when tested -- make sure you don't have any spaces at the beginning or end of your script.

查看更多
登录 后发表回答