dslc1000 Posted March 2, 2004 Posted March 2, 2004 Hi. I have been using something similar to the following code, and it works fine. $file = $HTTP_GET_VARS['file']; header("Content-type: audio/x-mp3"); header("Content-Disposition: attachment; filename=$file.mp3"); readfile("$file.mp3"); But when I change it to this it doesn't work, because there is other output before header() is called. (The reason I want to remove the "\"s from $file is because strings with apostrophes inherit them for some reason, and the files I'm trying to read aren't found as a consequence.) $file = $HTTP_GET_VARS['file']; //This part causes the problem because it's before header() is called $parts=explode("\",$file); $first=$parts[0]; $second=$parts[1]; $whole=$first.$second; header("Content-type: audio/x-mp3");//This is the line I get a parse error on header("Content-Disposition: attachment; filename=$whole.mp3"); readfile("$whole.mp3"); Can ob_start and ob_end_flush be used to get around this. I've tried a few things, but it's not working. Can anyone help me?
dslc1000 Posted March 2, 2004 Author Posted March 2, 2004 Ah, I've found the error of my ways! All I need do is replace: $parts=explode("\",$file); $first=$parts[0]; $second=$parts[1]; $whole=$first.$second; with: $whole=stripslashes($file); This doesn't cause a problem, while the other one does for some reason. Fingers crossed that it won't! I was a bit too hasty with my post!
Sayonara Posted March 2, 2004 Posted March 2, 2004 When I have problems like this, I search the forums on http://www.phpbuilder.com - you can always bet good money 382 people have asked the same question there before
dslc1000 Posted March 2, 2004 Author Posted March 2, 2004 Thanks for the tip! I'd actually enquired/searched on two other sites already, but didn't get any response, so decided to post here. I haven't been to http://www.phpbuilder.com before though.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now