ASP upload form validation

This is a discussion on ASP upload form validation within the Classic ASP & ASP.NET forums, part of the Development category; Hi all, I have inherited a ASP .NET website which I have to make changes to, and it has a ...


Reply
 
LinkBack Thread Tools Display Modes
Old 3rd November 2009, 03:51 PM   #1
Member
 
Join Date: Dec 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
craigfarrall is on a distinguished road
Default ASP upload form validation

Hi all,

I have inherited a ASP.NET website which I have to make changes to, and it has a big form on which has upload forms. I want to limit the size of the forms and have some validation on it. I want it to define, if the image is above 500kb then a javascript error comes up and says you need to resize the image, or if it is under 500kb then the form runs fine. I have the form working, just not the validation of the size of the upload file.

The form once submitted goes to an email, so the user can see the image (via url).

Here is the part of the form which is used:

Code:
if ((File2.PostedFile != null) && (File2.PostedFile.ContentLength > 0))
            {
                msg.Body += "<p><a href=\"http://www.youletdirect.co.uk/data/" + File2.PostedFile.FileName + "\">Image 2</a></b></p>";
                strFilePath = Server.MapPath("data") + "\\" + System.IO.Path.GetFileName(File2.PostedFile.FileName);
                MailAttachment attach2 = new MailAttachment(strFilePath);
                msg.Attachments.Add(attach2);
            }
and...

Code:
                    <h3>Photo 2 (max 200kb)</h3>
                    <asp:FileUpload ID="File2" runat="Server" /><br />
                    <br />
I can show the whole code, but thats the basics of it, and what I want. So if you need more, let me know.

Can anyone help with this, as I am struggling to get this working.

Thanks for your help
craigfarrall is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!twitter
Reply With Quote
Reply

Tags
upload, validation

« asp rss reader | - »
Thread Tools
Display Modes