473,563 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2888
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*******@tala mus.com" <es*****@att.ne t> wrote in message
news:OS******** ******@TK2MSFTN GP09.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.m icrosoft.com> wrote in message
news:pD******** ******@cpmsftng xa07.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
1955
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 has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution,...
1
353
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 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 ....
7
1692
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. Server side validation was being done for the description field having length and if not an appropriate message was written back to the client. ...
0
1122
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 arrow to switch to the next page everything works fine except that the htmlinputfile items looses their last input.
5
3100
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 images (just as you would with MS Word) and it works beautifully. The problem is that when you include an image with the rich text editor, the image...
2
1665
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 HtmlInputFile in my page and added some javascript code to a button to fire the click() event of the HtmlInputFile. It worked for a moment, but when the...
7
1748
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 (ByVal Value As String)
3
4547
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 HtmlInputFile control value is blank after the postback. The EnableViewState for the control is set to true. I can't put the postedFile.filename value...
7
1605
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 file must be 500 characters. I am adding the file to a site server library programmatically so if the field is too long I want to return the user to...
0
7580
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7882
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7945
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5481
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5208
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3634
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.