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 ... |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Member Join Date: Dec 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
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);
}
Code: <h3>Photo 2 (max 200kb)</h3>
<asp:FileUpload ID="File2" runat="Server" /><br />
<br />
Can anyone help with this, as I am struggling to get this working. Thanks for your help |
| | |
![]() |
| Tags |
| upload, validation |
| Thread Tools | |
| Display Modes | |