Jump to content

Recommended Posts

Posted

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?

Posted

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!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.