Home All Groups Group Topic Archive Search About
Author
29 Mar 2005 9:07 PM
newmem
Hi

In the webform, if a use selects a file to upload and submits the form. But
if page validation fails,  the HtmlInputFile loses the filename string and
the user has to re-select the file using the browse button.

Is there any way to persist the postedFile.filename during postback?

Appreciate any help.

Author
29 Mar 2005 9:11 PM
Brock Allen
The value in a <input type=file> is not allowed to be set by the page. The
browser always sets it to blank by default. This is for security, as malicious
websites could seed the control with a path to sensitive data on your machine.

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> Hi
>
> In the webform, if a use selects a file to upload and submits the
> form. But if page validation fails,  the HtmlInputFile loses the
> filename string and the user has to re-select the file using the
> browse button.
>
> Is there any way to persist the postedFile.filename during postback?
>
> Appreciate any help.
>
Are all your drivers up to date? click for free checkup

Author
29 Mar 2005 9:39 PM
newmem
Can I use client-side validation ? would the browser retain the value in the
<input type=file> control?


Show quoteHide quote
"Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
news:297019632477094716145888@msnews.microsoft.com...
> The value in a <input type=file> is not allowed to be set by the page. The
> browser always sets it to blank by default. This is for security, as
malicious
> websites could seed the control with a path to sensitive data on your
machine.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
> > Hi
> >
> > In the webform, if a use selects a file to upload and submits the
> > form. But if page validation fails,  the HtmlInputFile loses the
> > filename string and the user has to re-select the file using the
> > browse button.
> >
> > Is there any way to persist the postedFile.filename during postback?
> >
> > Appreciate any help.
> >
>
>
>
Author
29 Mar 2005 9:55 PM
Brock Allen
I've not tried too hard to make this work, but I don't even think client
side script allows you to set the value of the file input. Again, it's a
security risk, so hopefully this won't work for you. Sorry. ;)

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> Can I use client-side validation ? would the browser retain the value
> in the <input type=file> control?
>
> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
> news:297019632477094716145888@msnews.microsoft.com...
>
>> The value in a <input type=file> is not allowed to be set by the
>> page. The browser always sets it to blank by default. This is for
>> security, as
>>
> malicious
>
>> websites could seed the control with a path to sensitive data on your
>>
> machine.
>
>> -Brock
>> DevelopMentor
>> http://staff.develop.com/ballen
>>> Hi
>>>
>>> In the webform, if a use selects a file to upload and submits the
>>> form. But if page validation fails,  the HtmlInputFile loses the
>>> filename string and the user has to re-select the file using the
>>> browse button.
>>>
>>> Is there any way to persist the postedFile.filename during postback?
>>>
>>> Appreciate any help.
>>>
Author
29 Mar 2005 9:14 PM
Tampa.NET Koder
Are you inserting the runat="server" attribute within the tag itself?



Show quoteHide quote
"newmem" <""> wrote in message news:eqkhfNKNFHA.1948@TK2MSFTNGP14.phx.gbl...
> Hi
>
> In the webform, if a use selects a file to upload and submits the form.
> But
> if page validation fails,  the HtmlInputFile loses the filename string and
> the user has to re-select the file using the browse button.
>
> Is there any way to persist the postedFile.filename during postback?
>
> Appreciate any help.
>
>
>
Author
29 Mar 2005 9:19 PM
Alex
If you are having trouble with retrieving the name of the posted file, or
the location to the posted file, make sure the form in which this control
exists has the enctype="multipart/form-data" as seen below.

<form id="DefaultForm" method="post" runat="server"
enctype="multipart/form-data">
  </form>

When you upload your picture, you should be able to access it in your code
behind like this.

HttpPostedFile file = Request.Files["MyFileUpload"];

where the control is <INPUT name="MyFileUpload">

Hopefully I answered the right question for you.
--
Alex Mueller
Show quoteHide quote
"newmem" <""> wrote in message news:eqkhfNKNFHA.1948@TK2MSFTNGP14.phx.gbl...
> Hi
>
> In the webform, if a use selects a file to upload and submits the form.
But
> if page validation fails,  the HtmlInputFile loses the filename string and
> the user has to re-select the file using the browse button.
>
> Is there any way to persist the postedFile.filename during postback?
>
> Appreciate any help.
>
>
>

Bookmark and Share

Post Thread options