Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Hiding input type=file, access denied error

Reply
Thread Tools

Hiding input type=file, access denied error

 
 
hrpreet
Guest
Posts: n/a
 
      10-17-2006
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.

 
Reply With Quote
 
 
 
 
marss
Guest
Posts: n/a
 
      10-17-2006

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;

 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      10-17-2006
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 -
 
Reply With Quote
 
Tim Slattery
Guest
Posts: n/a
 
      10-17-2006
Randy Webb <> wrote:

>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

 
Reply With Quote
 
hrpreet
Guest
Posts: n/a
 
      10-19-2006
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 <> wrote:
>
> >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
>


 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      10-19-2006
hrpreet wrote on 19 okt 2006 in comp.lang.javascript:
> Tim Slattery wrote:
>> Randy Webb <> wrote:
>>
>> >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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very annoying error: Access to the path is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity Jay ASP .Net 2 08-20-2007 07:38 PM
Script for Hiding/Un-Hiding Text On Click Ste Javascript 41 08-01-2007 02:35 PM
Error 403 Forbidden - Access Denied by Access Control List Harroguk Computer Support 2 03-05-2007 10:53 AM
403 Forbidden: You were denied access because: Access denied by access control list Southern Kiwi NZ Computing 6 03-19-2006 05:19 AM
Web Service + Anon Access, but getting 401 Access Denied Error Alex Washtell via .NET 247 ASP .Net Web Services 1 04-05-2005 04:57 PM



Advertisments