File field control and Viewstate

G

Guest

All,

I have a ASP.NET/C# webform that contains two file filed control that have
been set to run as server controls i.e. Run As Server Control.

If the page_load I set the enableviewstate to true but when the form posts
back it looses the path of the file the user selected - what is wrong?

Thanks
Msuk
 
G

Guest

This behaviour is by design. The file control does not allow the value to be
set through code (either client or server side). This is for security as,
otherwise, anyone could set the value to the name of a file on the client
machine and upload it.

Alan
 
G

Guest

This is by design. You cannot set the value in a file control through code
(either client or server side). This is for security as, otherwise, anyone
could set the value to the name of a file on the client machine and upload it.

Alan
 
A

Anders Norås [MCAD]

I have a ASP.NET/C# webform that contains two file filed control that have
been set to run as server controls i.e. Run As Server Control.

If the page_load I set the enableviewstate to true but when the form posts
back it looses the path of the file the user selected - what is wrong?

The INPUT type=file HTML element uploads the file as multipart/form-data if
the following conditions are met:
* The element must be within a FORM with its method set to post and the
enctype must be multipart/form-data.
* The element must have its name attribute set.

When a file is uploaded, the filename is submitted along with the file.
However, the path of the file is available only to the machine within the
local machine security zone.

Anders Norås
http://dotnetjunkies.com/weblog/anoras
 

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

Top