473,489 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 8011

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9904
by: Ron Brennan | last post by:
Good afternoon. The entire task that I'm trying to achieve is to allow a user to browse and upload multiple files simultaneously, hiding the Browse button of <input> tags of type="file" and...
1
1440
by: Ersin Gentrk | last post by:
hi , I need to customize <input type=file , tag. I find a way to do that : on the client side by javascript and css first , I am hiding the fileupload object , then I am calling the click...
2
2161
by: Ersin Gentrk | last post by:
hi , I need to customize <input type=file , tag. I find a way to do that : on the client side by javascript and css first , I am hiding the fileupload object , then I am calling the click...
1
2837
by: HNguyen | last post by:
Access denied error while uploading a file to a web server. I am getting the following error while trying to upload a file to our web server: Error: Access to the path...
11
2345
by: TJM | last post by:
Hi, A Javascript error is generated when the user types a few character in an INPUT TYPE=FILE and hits a submit button. The form does not post. Is there a solution to this problem? Thanks TJM
4
9055
by: SammyBar | last post by:
Hi all, I wonder is it possible to upload the content of an <imgfield to a server. The content of the <imgwas downloaded from a web site different from the one it should be uploaded. The image...
6
3448
by: suresh_nsnguys | last post by:
Hi, This is my first message to this forum.I am facing one problem in frames.when i am trying to access child frame from parent frame i am getting "Access Denied Error".i know the reason bcz i...
8
2678
omerbutt
by: omerbutt | last post by:
hi there i have a form with multiple input (type/text ) fields and three inputs(type/file) fields i have to submit the form via ajax because i have multiple forms on this page ,you can say it is a...
6
4100
by: passionateforjava | last post by:
Hi All, I am using struts application wherein I need to import file for some purpose.I have used input type="file" for the same which goes like: <input type="file" id="uploadFile" name="uploadFile"...
0
7108
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7352
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
4875
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.