By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,932 Members | 1,454 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,932 IT Pros & Developers. It's quick & easy.

Hiding input type=file, access denied error

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a

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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.