Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
| Search | Today's Posts | Mark Forums Read
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 8th, 2012, 04:22 PM
Authorized User
Points: 194, Level: 3
Points: 194, Level: 3 Points: 194, Level: 3 Points: 194, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2011
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default Validating the size of a file being uploaded by the FileUpload control

Hi guys,

I have a little problem I'm struggling with here. I have a DetailsView control, which I have converted into templates and replaced some of its fields with regular server controls. One of such controls is the FileUpload control.

I want the user to be able to upload an image that will serve as a product avatar. The problem is, I need to make sure that the image being uploaded is not bigger than 2MB.

I am tapping into the DetailsView control's ItemInserting Event to get the file info from the FileUpload control and do a test on the size of the file before assing the e.Values property a file URL.

The problem is that the run time seems to be ignoring my chek for file size and going straight through the rest of the code.

The file size limit of the FileUpload control is determined by the httpRunTime element in the web.config file. I have set this element to accept only a file of size 2MB. However, I want a nice way to let the user know that they are trying to upload a large file.

So far, I am not getting any luck, my code is just being ignored and IE is displaying an unfriendly error message.

Can anyone help me out?

Thanks guys; you are the best!


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set limit fot uploaded photos size in PIXEL FeGan PHP How-To 0 December 3rd, 2011 01:10 PM
FileUpload control aliirfan84 ASP.NET 2.0 Professional 1 June 2nd, 2007 03:37 PM
how do i determine size of file being uploaded? kaos_frack Beginning PHP 3 January 10th, 2007 03:48 PM
FileUpload control -- file size detection ekwong ASP.NET 2.0 Basics 3 November 7th, 2006 06:32 PM
Verifying uploaded File Size in Client-side Ushhh ASP.NET 1.0 and 1.1 Professional 5 August 30th, 2006 07:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.