473,320 Members | 1,916 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,320 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 2874
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.