Forum Moderators: coopster

Message Too Old, No Replies

Force Download with multiple extensions

An extra string is added to the filename when forcing download

         

Drunkie

12:27 pm on Jul 22, 2005 (gmt 0)



I've got my script to work except for when I'm using multiple extensions, for example "raj.raj.exe". For some reason it adds a [1] in it so the filename to be downloaded results in "raj[1].raj.exe".

The code I'm currently using:

header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header("Content-Length: ".filesize($filename);
header("Content-Disposition: attachment; filename=\"".$filename."\"");

$handle = fopen(realpath($filename),"r");
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
print($buffer);
}
fclose($handle);
exit;

Anyone got an idea how to solve this?

Thanks in advance,
David

dmorison

5:34 pm on Jul 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi David,

I'm pretty sure that's not PHP doing that; it would have no reason to modify whatever the value of $filename was in your script.

Sticking [1] on the end of filenames sounds like the sort of thing the downloading browser / operating system would do when asked to download a file of the same name as one already on the disk. Have you checked that this is not the case...?