469,270 Members | 1,753 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Hiding input type=file, access denied error

Hi All,

I need the file chooser in the jsp, just for brosing and saving the
file path in the database, so i have used the following code.I dont
need to read the file content. I have to make it hidden because in
edit mode i need to show the field prepopulated with the file path,
which doesnot happen with input type=file, it cant be shown
prepopulated. But the following code gives access denied error.Please
help.

<html>
<head>
<script>
function browseFile(){

document.form.browse .click();
document.form.filename.value=document.form.browse. value;
return true;
}
</script>
</head>
<body>
<form name="test_form" method="post" action="test.jsp">
<input type=file name=browse style="display: none;">
<input type=text name=filename>
<input type=button value="Select a File..." onClick="browseFile();">
<input type=submit value="Submit The Form Now!">
</form>
</body>
</html>

Thanks for help.

Oct 17 '06 #1
5 7774

hrpreet написав:
Hi All,

I need the file chooser in the jsp, just for brosing and saving the
file path in the database, so i have used the following code.I dont
need to read the file content. I have to make it hidden because in
edit mode i need to show the field prepopulated with the file path,
which doesnot happen with input type=file, it cant be shown
prepopulated. But the following code gives access denied error.Please
help.

<html>
<head>
<script>
function browseFile(){

document.form.browse .click();
document.form.filename.value=document.form.browse. value;
return true;
}
</script>
</head>
<body>
<form name="test_form" method="post" action="test.jsp">
<input type=file name=browse style="display: none;">
<input type=text name=filename>
<input type=button value="Select a File..." onClick="browseFile();">
<input type=submit value="Submit The Form Now!">
</form>
</body>
</html>

Thanks for help.
document.test_form.browse.click();
document.test_form.filename.value=document.test_fo rm.browse.value;

Oct 17 '06 #2
hrpreet said the following on 10/16/2006 11:27 PM:
Hi All,

I need the file chooser in the jsp, just for brosing and saving the
file path in the database, so i have used the following code.I dont
need to read the file content. I have to make it hidden because in
edit mode i need to show the field prepopulated with the file path,
which doesnot happen with input type=file, it cant be shown
prepopulated. But the following code gives access denied error.Please
help.
You get that error message because you can't programatically set the
value of a file input element. It's a security violation.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
Oct 17 '06 #3
Randy Webb <Hi************@aol.comwrote:
>You get that error message because you can't programatically set the
value of a file input element. It's a security violation.
He's not trying to. He's retrieving the value of the <input
type="file"...and assigning that to an <input type="text"...>
element.

Why he needs to do that, I don't understand. The "file" element
includes a text box that gets set to the name of the file selected. It
seems that would show the exact same thing that he's trying to show in
his "text" box.

--
Tim Slattery
Sl********@bls.gov
Oct 17 '06 #4
Hi All,

This is required since in case of updation need , i need to show the
file text box prepopulated, but this doesnot happen, not allowed.

Thanks

Tim Slattery wrote:
Randy Webb <Hi************@aol.comwrote:
You get that error message because you can't programatically set the
value of a file input element. It's a security violation.

He's not trying to. He's retrieving the value of the <input
type="file"...and assigning that to an <input type="text"...>
element.

Why he needs to do that, I don't understand. The "file" element
includes a text box that gets set to the name of the file selected. It
seems that would show the exact same thing that he's trying to show in
his "text" box.

--
Tim Slattery
Sl********@bls.gov
Oct 19 '06 #5
hrpreet wrote on 19 okt 2006 in comp.lang.javascript:
Tim Slattery wrote:
>Randy Webb <Hi************@aol.comwrote:
>You get that error message because you can't programatically set the
value of a file input element. It's a security violation.

He's not trying to. He's retrieving the value of the <input
type="file"...and assigning that to an <input type="text"...>
element.

Why he needs to do that, I don't understand. The "file" element
includes a text box that gets set to the name of the file selected. It
seems that would show the exact same thing that he's trying to show in
his "text" box.
[Please do not toppost on usenet]
This is required since in case of updation need , i need to show the
file text box prepopulated, but this doesnot happen, not allowed.
If you change "need" to "want" you are right.

However, security is about not always getting what you want.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 19 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ersin Gentrk | last post: by
2 posts views Thread by Ersin Gentrk | last post: by
11 posts views Thread by TJM | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.