Hi Shimon,
Thank you for using MSDN Newsgroup! My name is Steven, and I'll be
assisting you on this issue.
From your description, you'd like to use the HtmlInputFile control to
upload file. And you'll do some validation before upload file. However,the
problem is that you found that after the page posted back, all the path
infos of the HtmlInputFile Controls will lose. Also its path property is
readonly which makes it unable to manually set it. Also, since this
problem, you're considering other ways to upload files.
If there is anything I misunderstood, please feel free to let me know.
As for the above problems, I think they are all caused by the same issue:
we cannot manipulate HtmlINputFile control's file path info. In fact the
HtmlInputFile control is a wrapper fo the <input type="file" /> html
element. Why we can't specify its value manuallly is for some security
reasons. And here is a Knowledge base article which has explained this
limit:
#Cannot Use Script to Manipulate INPUT TYPE=File Value
http://support.microsoft.com/?id=266087
As for your situation, do you think we could use some other means. Since
you'd like to do some validation before the files are uploaded(use some
labels to display the path info), would you like to use some client side
javascript to get the path info and display to the user? Thus, the page
won't be posted back to the server and the InputFile controls' path
property's value can remain.
Or you may search for some third party upload controls, but most of them
also encapsulate <input type="file" /> html control.
Also, I think Steve's suggestion that put each HtmlInputFile control in a
separate frame page(or iframe) is a way if you don't have many such
controls in the page. But it'll make things abit complex.
In addition, if you do want to use other ways rather than using the
HtmlInputFile control(or <input type="file" />) to upload file. You may
have to use some ACTIVEX or other rich client approachs which contains
unsafe code for client side and somewhat too complex. In fact, I do
recommemd that you still use the InputFile control as it's easy and
convenient to use.
Please check out the preceding information and suggestions. If you have any
quesitons or need any help, please feel free to post here.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)