- Today I will show you that how to Upload Image in web application in ASP.NET to Use Visual Studio 2008 OR 2012.
- Create table 'photo' in database. Field name:- images, img_name.
- We can create many tables in one database.
- First We required some control like that textbox, fileupload, and button. And you have to make new folder in your web application
- Now we take two namespace.
using System.Data; //not requerd to use this namespace in Visual Studo 2008.
Now in the class we write the connection object and other objects for Upload Image
SqlCommand cmd; //interecting with the database means take the action in database like ad insert, update, delete. no required in log in program.
SqlDataAdapter adp; // read the data from the database. ,always take this object wheneve establist the connection
- Now we write code in Upload button.
- If You want to only upload image, you write only this code.
string str3 = "~/imgfolder/" + FileUpload3.FileName; // add folder name which is make in your webapplication
FileUpload3.SaveAs(Server.MapPath(str3));
- Or else Upload Image With add in database. You Write this code.
FileUpload3.SaveAs(Server.MapPath(str3)); cmd = new SqlCommand("insert into dt values('" + str3 + "','" + TextBox1.text + "')", conn);
cmd.ExecuteNonQuery();
conn.Close();
Now Your Web application is ready to run.
GET FULL EXAMPLE
if You any Query in php or get Example of php click on :- PHP EXAMLE
No comments:
Post a Comment