We have seen this type of functionality in many online registration forms, usually in government exams, where we have to upload the image but with the given dimensions. This article is also similar to that where we will upload the image to the database but with the given dimension, if the image is in a proper dimension it will save it to the database, otherwise it will show you an error.
Initial Chamber:
Step1: Open Visual Studio 2010 and create an Empty Website, Give a suitable name, I have given FileUpload_demo here.
Step2: In Solution Explorer you get your empty website, Add a web form, SQL Database. Here are the steps,
For Web Form:
FileUpload_demo (Your Empty Website): Right Click, Add New Item, then click Web Form. Name it Fileupload_demo.aspx.
Again get back to your website in Solution Explorer and Add New Folder and give name New Folder, then click Upload.
For SQL Server Database:
FileUpload_demo (Your Empty Website): Right Click, Add New Item, SQL Server Database. Add Database inside the App_Data_folder.
DATABASE CHAMBER:
Step 3 : Go to your Database Database.mdf, we will create a table - tbl_Data, Go to the database.mdf, Table, then Add New table, design your table like this:
Table - tbl_img (Don’t forget to make ID - Identity Specification, then select Yes)

DESIGN CHAMBER:
Step 4:
Open your Fileupload_demo.aspx file to create our design, we will drag a HTML table, a FileUpload control, a button and a label. From FileUpload we will browse the image, on the submit button, it will check the dimension of the image, if it is proper in dimension it will show you a success message.
Fileupload_demo.aspx
- <%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%>
- <!DOCTYPE htmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- <style type="text/css"> .style1 { width: 243px; } </style>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <table style="width:100%;">
- <tr>
- <td class="style1">
- <asp:FileUploadID="FileUpload1" runat="server" /> </td>
- </tr>
- <tr>
- <td class="style1">
- <asp:LabelID="Label1" runat="server"></asp:Label>
- <asp:LabelID="Label2" runat="server"></asp:Label>
- </td>
- </tr>
- <tr>
- <td class="style1">
- <asp:ButtonID="Button1" runat="server" Text="Upload" onclick="Button1_Click" /> </td>
- </tr>
- </table>
- </div>
- </form>
- </body>
- </html>







Vivek KumarPosted Apr 17, 2016, 6:34 AM
Good one
Kuppurasu NagarajPosted Apr 17, 2016, 4:12 AM
Nice Sharing..
Pankaj Kumar ChoudharyPosted Apr 16, 2016, 11:41 AM
Nice Explain Nilesh ! Happy to see u again..........
Gowtham KPosted Apr 16, 2016, 8:56 AM
Good One, Thanks for sharing:)
Vignesh ManiPosted Apr 16, 2016, 8:33 AM
Nice