473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

HtmlInputFile control looses information after post back.

Hi,
I need to upload pictures from client machine and I am using HtmlInputFile
control I set validator to make sure that file has correct expention but if
one of the files has incorrect extention all information in other controls
gets lost. I can't find the way to save pathes and then assign them to
control - the Value property is read only .

Besides this I need to create conformation page before subtission of the
files. On the submission page I just display labels with file pathes. How do
I upload files without this control.
Thanks,
Shimon.
Nov 18 '05 #1
5 2880
As you've discovered, this functionality is not very flexible from a
developer's standpoint. That's because this is a very delicate area from a
security perspective. Web sites should not be able to upload files from a
user's computer without their clear consent. That's why the control behaves
this way.

One way to try and counteract the negative side effects is to put the
control in it's own page: Either by putting it in it's own frame or popping
it up in a new window.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com


"sh*******@talamus.com" <es*****@att.net> wrote in message
news:OS**************@TK2MSFTNGP09.phx.gbl...
Hi,
I need to upload pictures from client machine and I am using HtmlInputFile
control I set validator to make sure that file has correct expention but if one of the files has incorrect extention all information in other controls
gets lost. I can't find the way to save pathes and then assign them to
control - the Value property is read only .

Besides this I need to create conformation page before subtission of the
files. On the submission page I just display labels with file pathes. How do I upload files without this control.
Thanks,
Shimon.

Nov 18 '05 #2
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.)

Nov 18 '05 #3
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.)

Nov 18 '05 #4
Hi Shimon,

Have you checked out my suggestion or have you got any progress on this
issue. If you 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.)

Nov 18 '05 #5
I am sorry for not posting my answer right away.
I decided that I should save files and their path to server variable and for
change page just show paths that could be edited one by one. If user decides
to edit I will update the file in the variable.
When user confirms I am writting all the files in the same time.
Thanks,
Shimon.
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:pD**************@cpmsftngxa07.phx.gbl...
Hi Shimon,

Have you checked out my suggestion or have you got any progress on this
issue. If you 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.)

Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Skwish | last post by:
Hi, I have a page with a htmlInputFile that is working fine. However, if I go to another page, and then go back to the page with the htmlInputFile, I get the following error Warning: Page...
1
by: shimonsim | last post by:
Hi, I need to upload pictures from client machine and I am using HtmlInputFile control I set validator to make sure that file has correct expention but if one of the files has incorrect extention...
7
by: Al Smith | last post by:
Newbee to aspx needs direction. We are using an <INPUT type="file" tag to upload a file. We also have a text field for the user to enter a description for the file which the user must enter. ...
0
by: mizd | last post by:
Hi, does anybody have a hint how to solve this. I have a datagrid with a template column (all in code behind technique). the datagrid has paging with ten items. when I select the paging...
5
by: Grant Harmeyer | last post by:
I have an application that uses FreeTextBox 2.0 (http://www.freetextbox.com). FreeTextBox is a rich text editor that behaves similarly to MS Word. The FreeTextBox control has a button to insert...
2
by: Augusto Cesar via DotNetMonster.com | last post by:
Hi, I want to customize the HtmlInputFile. I wanna something like an image button to play the "browse" button hole and hide the textbox. Is that possible? I also have tried to hide an...
7
by: Buddy Ackerman | last post by:
I created this class Public Class HTMLFileInput : Inherits System.Web.UI.HtmlControls.HtmlInputFile Public Property Data As String Get Return ViewState("HTMLFileInput.Data") End Get Set...
3
by: Dave Adler | last post by:
Is there any way to retain the value of an HtmlInputFile control through a postback? I do some server side validation on the page when it is submitted and if an error occurs on the page the...
7
by: cindy | last post by:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to submit files. Before the file is successfully submitted I validate another field on the form, it is the description of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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 project—planning, coding, testing,...
0
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...

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.