In this article, I will show you how to save an image in the database using FileUpload control in ASP.NET.
We will save the name and path of the image to the database. Initial chamber Step 1: Open Visual Studio 2010 and create an empty website. Give it a suitable name: FileUpload_demo. Step 2: In Solution Explorer you will get your empty website. Add a web form and SQL Database like the following: For Web Form: FileUpload_demo (Your Empty Website) - Right Click, Add New Item, then click Web Form. Name it Fileupload_demo.aspx. Go back to your website in Solution Explorer and Add New Folder and Give name as - New Folder, then Upload. For SQL Server Database: FileUpload_demo (Your Empty Website) - Right Click and Add New Item, then click 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. Also, go to the database.mdf - Table and add new table, design your table like this: Table - tbl_data ([Don’t forget to make ID, then Identity Specification as Yes). Design chamber Step 4: Open Fileupload_demo.aspx file to create our design, we will drag an HTML table, a FileUpload control, button, label and a textbox. Fileupload_demo.aspx
Programming ASP.NET MVC 5