# Automatic Download Button w/ PHP function Problem!

**URL:** https://forum.kirupa.com/t/automatic-download-button-w-php-function-problem/137093
**Category:** Uncategorized
**Created:** [February 11, 2005, 4:27am UTC](https://forum.kirupa.com/t/automatic-download-button-w-php-function-problem/137093 "2005-02-11T04:27:16Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![esa1234](https://avatars.discourse-cdn.com/v4/letter/e/a183cd/32.png) [@esa1234](https://forum.kirupa.com/u/esa1234)
#### Post date: [February 11, 2005, 4:27am UTC](https://forum.kirupa.com/t/automatic-download-button-w-php-function-problem/137093/1 "2005-02-11T04:27:16Z")

</div>

Hello,  
This is my first post to the forum…not because I havent used the forums, I have. Everyone here is amazing at what they do, I’m a novice and a learner.

Anyway…I need help. I have code I found from here and other places that does the following. In a movie I have created a button that, when pressed, will load a window which uses php code to intiate a download automatically. The thing is, it works in Firefox, but not in Internet Explorer. I have NO CLUE why.

Here my code:

1. the movie clip’s button has AS that looks like this:

on (release) {

```
address = "http://www.cat-a-tac.com/mp3/thispage.php?filename=AllIKnew.mp3", "_blank";
target_winName = "http://www.cat-a-tac.com/enjoy.html";
width = 100;
height = 100;
toolbar = 0;
location = 0;
directories = 0;
status = 0;
menubar = 0;
scrollbars = 0;
resizable = 1;
// sends data back to the function
openWinCentre(address, target_winName, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable);

```

}

—The end result of which is to make songs on my band’s website automatically download (or bring up the “save to disk” option).

1. Here’s the php code I’m using:

\<?php  
$filename = $\_GET[‘filename’];  
if (ereg(".mp3$", $filename)) {  
header(“Pragma: public”);  
header(“Expires: 0”);  
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);  
header(“Content-Type: application/force-download”);  
header(“Content-Type: application/octet-stream”);  
header(“Content-Type: application/download”);  
header(“Content-Disposition: attachment; filename=”.basename($filename).";");  
header(“Content-Transfer-Encoding: binary”);  
header(“Content-Length: “.filesize($filename));  
readfile(”$filename”);  
}  
?\>

—So, there it is…I really have only a general idea of what specifically the code is doing. I learned it just enough so that I could implement the code into my website. The whole thing is a work-around to the “Right Click to Save As” not existing in flash mx 2004. If anyone out there can help with this I’d be very appreciative. Thanks!!!

Cheers,  
esa
