i am making a website on online shopping using asp.net and sql server 2008...
now i am creating the database for it where i have started making the
first table as item_details which has a column as item_image where i
need to store the image url..so how can i do this please help....
Loading
Pankaj PandeyPosted May 20, 2013, 4:35 AM
string Filename = FileUpload1.FileName;
string FilePath = Server.MapPath("~//" + Filename);
FileUpload1.SaveAs(FilePath);
Now you can store FilePath to your table and use it as your need.
Mark answered if usefull.
thanks
Sandeep Singh ShekhawatPosted May 20, 2013, 3:36 AM
You are using fileupload control then do
if (FileUpload1.HasFile)
{
//Get file name
string filename = System.IO.Path.GetFileName(FileUpload1.FileName);
//get full server file path with name where we save file
string filePath = Server.MapPath("~//" + filename);
//Save/upload file on server
FileUpload1.SaveAs(filePath);
//Here you can pass filePath variable to database that contains full file path means full url like
SqlConnection con =new SqlConnection(connesctionString);
cmd.ExecuteNonQuery();
}