Hiding input type=file, access denied error

H

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.
 
M

marss

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_form.browse.value;
 
R

Randy Webb

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.
 
T

Tim Slattery

Randy Webb said:
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.
 
H

hrpreet

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
 
E

Evertjan.

hrpreet wrote on 19 okt 2006 in comp.lang.javascript:
[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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,838
Latest member
KandiceChi

Latest Threads

Top