Problem with <Input type = file.../>

Hi,

i have a situation where i would like to use the

"click()" method of Input Type 'File' control.

The steps followed by me.

1.I put a Input type File control and i made it

invisible

2.I put one Button control and one Text control.

3.I am calling the "click()" method of File control

from the OnClick event of the button control.

4.Then i am assigning the File value to the Text

control.

5.I put one more Button control.

6.Then Onclick event of this button i am calling

"SubmitPage" function to submit the page to an target

asp file.

When i run this page and on clicking the Send button i

am getting an error as "Access is denied".

If u find the solution for this please clarify me.

Regards

PSNathan.

The code used by me :

<HTML>

<HEAD>

<SCRIPT LANGUAGE="Javascript">

function FileClick()

{

document.frmSample.Text1.value =

document.frmSample.File1.value;

}

function SubmitPage()

{

document.frmSample.action = "Target.JSP"

document.frmSample.submit();

}

</SCRIPT>

</HEAD>

<BODY>

<FORM Name="frmSample" Method="post" Action="">

<INPUT Type="file" Name="File1"

Style="Display:none">

<INPUT Type="text" Name="Text1" Value="">

<Input type="button" name="But1" value="Open"

OnClick=Javascript:File1.click();FileClick()>

<INPUT Type="button" Name="But2" Value="Send"

OnClick="SubmitPage()">

</FORM>

</BODY>

</HTML>

[1713 byte] By [RDJ42] at [2007-11-25 19:54:12]
# 1

...............

1 <INPUT Type="text" Name="Text1" Value="">

2 <Input type="button" name="But1" value="Open"

3 OnClick=Javascript:File1.click();FileClick()>

4 <INPUT Type="button" Name="But2" Value="Send"

5 OnClick="SubmitPage()">

.................

i face this problem my friend and i found the solution.

modify line three to become as this

OnClick=Javascript:File1.click();FileClick();return false;>

Tvirus at 2007-7-4 13:31:37 > top of Java-index,Web & Directory Servers,Portal Servers...
# 2
tried using your soln but it is still giving out tha access denied error.
@ack at 2007-7-4 13:31:37 > top of Java-index,Web & Directory Servers,Portal Servers...
# 3

It is my understanding that the .click() method and .value fields are not available for <input type="file"> in some browsers.

The Mozilla-based browsers like Firefox are one such case. The only solution that appears viable is to make creative use of CSS layers to put the "visible" custom Browse button under the real Browse button and making the real Browse button transparent. That way the user only sees your custom button (not the unstyled Browse button of <input type="file"> and clicks the unstyled one when he thinks he is clicking yours.

Lame, I know, but it seems to be the only thing that can be done considering the lousy job that the W3C did with styling <input type="file">.

Good luck.

bmelloni at 2007-7-4 13:31:37 > top of Java-index,Web & Directory Servers,Portal Servers...
# 4
Hi,Can you please let me know if you have got a solution for this problem? I am facing the same problem and have no clue abt what to do.Thanks,BiS
bismia at 2007-7-4 13:31:37 > top of Java-index,Web & Directory Servers,Portal Servers...
# 5
This might solve your problem. http://www.quirksmode.org/dom/inputfile.html.Let me know if it works for you.
NileshNaik at 2007-7-4 13:31:37 > top of Java-index,Web & Directory Servers,Portal Servers...
# 6
Hi,This is the problem because the file which you are trying to upload maybe a read only file.thanksAnurag
anurag1005 at 2007-7-4 13:31:37 > top of Java-index,Web & Directory Servers,Portal Servers...
# 7

I am facing a problem which is kind of similar but the problem arises only if the browser is Firefox on WIndows OS. This is while uploading a file with any east asian characters in its filename. IE works fine and uploads the approrpaite file, but Firefox for some reason converts each east asian characters to "_".

For E.g., if your file name is 6<3 japanese characters>.txt

firefox changes the name as 6.txt (3 underscore characters). Eventually, the code to upload the file from the directory fails with File NOt Found error, since it is actually looking for a file named "6.txt"

Can somebody help me resolve this issue?[

blore_girl at 2007-7-4 13:31:37 > top of Java-index,Web & Directory Servers,Portal Servers...
# 8

hi all,

The input type=file cannot be prepopulated, the only way

for doing is either clicking browse button directly or type the filename in the box provided beside browse.

This has been with the design itself. The intent was to prevent malicious users from, loading files by prepopulating.

Regards,

Varma

Varma at 2007-7-4 13:31:37 > top of Java-index,Web & Directory Servers,Portal Servers...
# 9

> This might solve your problem.

>http://www.quirksmode.org/dom/inputfile.html.

> me know if it works for you.

Hi -- has anyone made either the css layers or the JS workaround for this work?

The author posts his code in snippets and I seem to have missed something....?

Symbol123 at 2007-7-4 13:31:37 > top of Java-index,Web & Directory Servers,Portal Servers...