Click to See Complete Forum and Search --> : Function to open file dialog?


slevytam
01-10-2003, 10:45 PM
Hello everyone,

I really need some help with this.

I'm looking for netscape and ie instructions.

I have a button
<FORM ENCTYPE="multipart/form-data" ACTION="/scripts/aspSmartUpload/upload.asp?MYPARAM=test">
<INPUT TYPE="FILE" NAME="upload">
</FORM>

I would like to call the onclick of this button from a function on the page.

In other words I would like a function to open the file dialog box. This function MUST work in both ie and netscape.

Please, please help

Thank you,

--SL

khalidali63
01-10-2003, 11:33 PM
Is this something you were looking for?

Khalid


<html>
<head>
<title>Untitled</title>
</head>

<body>
<FORM name="form1" ENCTYPE="multipart/form-data" ACTION="/scripts/aspSmartUpload/upload.asp?MYPARAM=test">
<INPUT TYPE="File" NAME="upload" onchange="uploadFile();">
</FORM>
<script>
function uploadFile(){
var frm = document.form1;
var file = frm.upload.value;
if(file.length>1){
alert("You have selected \n"+file+"\nFIle to upload");
}
}
</script>

</body>
</html>

slevytam
01-10-2003, 11:59 PM
I don't think so?...

I am looking to do something like this:

I just can't figure out the syntax for ie and most importantly netscape...

<html>
<head>
<title>Upload</title>
<SCRIPT LANGUAGE=JavaScript>
function up()
{
document.all['upload'].click();
}
</SCRIPT>
</head>

<body onload=up()>
<FORM ENCTYPE="multipart/form-data" ACTION="/scripts/aspSmartUpload/upload.asp?MYPARAM=test">
<INPUT TYPE="FILE" NAME="upload">
</FORM>

</body>
</html>

The line I need help with is document.all['upload'].click()
This doesn't work!(at least in netscape).

Is this clearer? I am trying to write a function that opens the file dialog box. An image or something else would be able to call the function and open the file dialog.

Thanks,

--SL

khalidali63
01-11-2003, 09:34 AM
Well the code below will work in IE,
For NS,its completely other story.


<html>
<head>
<title>Untitled</title>
</head>

<body>
<FORM id="form1" name="form1" ENCTYPE="multipart/form-data" ACTION="/scripts/aspSmartUpload/upload.asp?MYPARAM=test">
<INPUT TYPE="File" id="upload" name="upload" value="upload"><br>
<INPUT TYPE="Button" value="upload" onclick="uploadFile();"><br>
</FORM>
<script>
function uploadFile(){
var frm = document.form1.upload;
if(document.all && document.getElementById){
document.form1.upload.click();
}
}
</script>

</body>
</html>

slevytam
01-11-2003, 11:51 AM
I am going to be calling the up function from flash. This will open the file dialog box without the need for the html form. Ie the html form will be invisible to the user.

This works perfectly in ie but I can't seem to get netscape to open the file dialog box. If I could, then I would be able to have flash upload files without the user having to see any html.

Thanks,

--SL

netscape 6 or 7 must have something?...

slevytam
01-11-2003, 02:22 PM
This makes sense; however, there must be a way around it. I am desperate and willing to try anything. JAVA perhaps? ActiveX?

Sorry for a being a pain,

--SL