473,569 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileUpload Control question

Hi All,

I am using the FileUpload control for the ASPX page. How do you disable the
text box portion of that control, so I can force the user only to pick up a
file via the Browser button, and not to type any file name that does not
exists.

Thanks,

Joe
Oct 11 '07 #1
10 4709
For security reason you can not force the user to what you want.

"JoeP" <Jo**@hotmail.c omwrote in message
news:ez******** ******@TK2MSFTN GP05.phx.gbl...
Hi All,

I am using the FileUpload control for the ASPX page. How do you disable
the text box portion of that control, so I can force the user only to pick
up a file via the Browser button, and not to type any file name that does
not exists.

Thanks,

Joe

Oct 11 '07 #2
What kind of security issue are we talking here?

Is there any other way to validate that there is a real file out there?
Otherwise the user just can just type anything in that textbox.

Appreciate any feedback or any other suggestions.

Thanks,

Joe
Oct 11 '07 #3
JoeP,
In ASP.NET 2.0 VS2005
if the user types a full filename that does not exist then your submit
button does not do anything.
if the user types a good filePath Name then at the server level you can
check the name etc.

The File Upload control does not give us the developers the capability to
dynamically change what file to upload.
There is a general security lock on what we can see and do on the client
side.

You can write an ActiveX, JAVAApplet or a SilverLight ( using C# or VB.NET
or others ) to have an upload file that can deal with what you want
including selecting and uploading multiple files at once with multiple
selects.
In this case the client is consenting to allow you to poke around.

"JoeP" <Jo**@hotmail.c omwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
What kind of security issue are we talking here?

Is there any other way to validate that there is a real file out there?
Otherwise the user just can just type anything in that textbox.

Appreciate any feedback or any other suggestions.

Thanks,

Joe


Oct 11 '07 #4
OK if the submit does not do anything, is there away to trap that action and
have a message for the user? I have other fields and I can validate them
using RequiredFieldVa lidator, but that's done in the client side.

Thanks,

Joe
Oct 11 '07 #5
good question,
even if you intercept the submit button event on the client side How would
you know if the file path is valid.

I don't have a good answer.

I hope someone else can give me and you an answer.

What file do you except and what files you don't except.

even if the name is correct and the extension is correct the file might not
have the correct content for the extension given.

Sometimes you just need to accept what can be done and move on.

I am still hoping for an answer myself.

"JoeP" <Jo**@hotmail.c omwrote in message
news:eO******** *****@TK2MSFTNG P06.phx.gbl...
OK if the submit does not do anything, is there away to trap that action
and have a message for the user? I have other fields and I can validate
them using RequiredFieldVa lidator, but that's done in the client side.

Thanks,

Joe

Oct 11 '07 #6
Thanks for your reply.
I see your point. How would you limit the size of the file to 8MB?

Is that possible via the Web.Config?
Oct 11 '07 #7
re:
!Is that possible via the Web.Config?

In web.config...

<httpRuntime maxRequestLengt h="8192"/>

....will limit uploads to 8MB in size.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== ========
"JoeP" <Jo**@hotmail.c omwrote in message news:ef******** ******@TK2MSFTN GP02.phx.gbl...
Thanks for your reply.
I see your point. How would you limit the size of the file to 8MB?

Is that possible via the Web.Config?

Oct 11 '07 #8
In my case I changed it in my Machine.config
But I think if you put it in web.config then it overrides the one in
machine.

Stolen instruction from http://forums.asp.net/p/1048294/1948278.aspx

One of the great things about .NET, however, is that it usually provides a
way around limitations. You can usually change the default settings that are
in place. To change this size limit, you make some changes in either the
web.config.comm ents (found in the ASP.NET 2.0 configuration folder at
C:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727 \CONFIG) or your application's
web.config file.

In the web.config.comm ents file, find a node called <httpRuntimetha t looks
like the following:

<httpRuntime
executionTimeou t="110"
maxRequestLengt h="4096"
requestLengthDi skThreshold="80 "
useFullyQualifi edRedirectUrl=" false"
minFreeThreads= "8"
minLocalRequest FreeThreads="4"
appRequestQueue Limit="5000"
enableKernelOut putCache="true"
enableVersionHe ader="true"
requireRootedSa veAsPath="true"
enable="true"
shutdownTimeout ="90"
delayNotificati onTimeout="5"
waitChangeNotif ication="0"
maxWaitChangeNo tification="0"
enableHeaderChe cking="true"
sendCacheContro lHeader="true"
apartmentThread ing="false" />
A lot is going on in this single node, but the setting that takes care of
the size of the files to be uploaded is the maxRequestLengt h attribute. By
default, this is set to 4096 kilobytes (KB). Simply change this value to
increase the size of the files that you can upload to the server. If you
want to allow 10 megabyte (MB) files to be uploaded to the server, set the
maxRequestLengt h value to 11264, meaning that the application allows files
that are up to 11000 KB to be uploaded to the server.

Making this change in the web.config.comm ents file applies this setting to
all the applications that are on the server. If you want to apply this to
only the application you are working with, apply this node to the web.config
file of your application, overriding any setting that is in the
web.config.comm ents file. Make sure this node resides between the
<system.webnode s in the configuration file.

Another setting involved in the size limitation of files to be uploaded is
the value given to the executionTimeou t attribute in the <httpRuntimenod e.

The value given the executionTimeou t attribute is the number of seconds the
upload is allowed to occur before being shut down by ASP.NET. If you are
going to allow large files to be uploaded to the server, you are also going
to want to increase this value along with the maxRequestLengt h value.

One negative with increasing the size of a file that can be uploaded is that
there are hackers out there who attack servers by throwing a large number of
requests at them. To guard against this, you can actually decrease the size
of the files that are allowed to be uploaded; otherwise, you may find
hundreds or even thousands of 10 MB requests hitting your server.

"JoeP" <Jo**@hotmail.c omwrote in message
news:ef******** ******@TK2MSFTN GP02.phx.gbl...
Thanks for your reply.
I see your point. How would you limit the size of the file to 8MB?

Is that possible via the Web.Config?

Oct 11 '07 #9
Thanks Juan.
Oct 11 '07 #10

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

Similar topics

2
2926
by: Islamegy® | last post by:
I'm use FormView for editing a photo gallery... I add FileUpload control to upload images to the Gallery. I'm binding my Formview to objectdatasource i tried upload images onItemInserting & onItemUpdating but no luck.. FindControl() didn't work and can't find my fileUpload control.. any help plzzzzzzzzzz?? I just upgraded to .net 2 and...
1
7033
by: Marko Vuksanovic | last post by:
I am trying to implement an upload progress indicator using atlas, using the following workaround: http://forums.asp.net/thread/1321664.aspx This is the code in FileUpload.apsx file is as follows: <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title> drag </title> </head> <body> <form id="f1"...
4
5666
by: Dave | last post by:
If you had a FileUpload control inside of a FormView...how would you use FindControl to access the FileUpload properties? Let me just say that (FileUpload)FormView1.FindControl(FileUpload1).FileName doesn't work. The purpose is to insert a graphic in the InsertItemTemplate section of the form. I'm using the expample that's in the online...
3
5163
by: rn5a | last post by:
The ASPX FileUpload control displays a TextBox along with a 'Browse...' Button. Setting the different properties of this control just reflects the changes in the TextBox but not the Button. For e.g. if the BackColor of a FileUpload control is set to blue, then only the TextBox color changes to blue but the BackColor of the Button doesn't...
5
12077
by: =?Utf-8?B?QmVydA==?= | last post by:
Hi How can you set the filename property in the asp:fileupload control? How can you persist the value of the chosen filename between postbacks? thanks B
2
11381
by: ronc85 | last post by:
My environment is ASP.NET 2.0, C# and AJAX. Is there a way to retain the Postedfile in the FileUpload control after Postback? I have this application I've inherited were the User chooses a file then clicks the "save" button, the program proceeds to edit the file on the server and if it detects an error displays an error message. At this...
9
9723
by: vital | last post by:
Hi, I have a User control which has a fileupload control. With the requirements I placed the user control in a UpdatePanel of ASP.NET Ajax and the fileupload.postedfile.filename giving error. I read some articles that Ajax is not compatible with fileupload. I want to know the solution or workaround for this. Thanks
2
5985
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have a gridview with 2 columns. One column is a BoundColumn to a part number (string). One column is an ItemTemplate with a FileUpload control. There can be multiple rows (i.e. part numbers) in the gridview. The user attaches a file for each part number / row. The user clicks a button after attaching all the needed files.
6
229
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
I have created a simple fileupload page for image files. It woulds without problem with ie7. However, FireFox and Safari will not upload an image file. Is there some issue with the control and those browsers? I have created a class to handle these operations, but i don't see this a factor. Thanks you -- Share The Knowledge. I need all...
2
1039
by: miladhatam | last post by:
hi i want make a page that users can upload their picture but my problem : how can i dynamically add this control cos i want that they can upload every pic they have and like gmail if you browse a file in page automaticaly add a fileupload control in below of last control can you help me ? thanks
0
7924
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
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
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
5219
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
3653
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
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.