View Full Version : browse for file window on a flash button

08-17-2005, 01:56 PM
Hi everyone, I am looking for a way to attach files to my email forms. Does anyone know the javascript to bring up the browse for file window and how I can put that code on a button in Flash? Thanks so much.

08-17-2005, 03:21 PM
There is no javascript code for that*.
Use a file input for html.
How one does this in Flash, I have no idea. They probably have a file input control...?

*cross-browser javascript. MSIE jscript/hta can.

There is no javascript code to just invoke Windows' file browse control. I should have been more specific.

08-17-2005, 05:27 PM
NikkiH - You are right - this can't be done in solely flash - there is no file input form element. But, you can force a hack in IE

This only currently works in IE, but am gonna upgrade with Mozilla compatible code (hopefully) after work.

Should give you some ideas. Here's the JS for those who don't wish to download the zip.

function fileBrowser() {
var _d = document.createElement("div");
with(_d.style) {
visibility = "hidden";
display = "none";
var _f = document.createElement("form");
var _i = document.createElement("input");
_i.type = "file";
_i.id = "elFileBrowser";
_i.onchange = function() {
document.getElementById("flashID").SetVariable("path", this.value);


if(typeof document.getElementById("elFileBrowser").click() == "undefined") {
// do stuff for gecko DOM
} else {

If anyone knows how to force the click in Gecko, then please feel free to post up =)


08-17-2005, 07:40 PM
So you're creating a file input, then invoking its click event...
For Gecko, look at createEvent, initEvent, and dispatchEvent.

Lawn Gnome
08-18-2005, 06:41 AM
hey how do i make the thing send it to me??? :confused: