You can save image in folder and image path in database for this
bool CheckFileType(string fileName)
{
string ext = Path.GetExtension(fileName);
switch (ext.ToLower())
{
case ".gif":
return true;
case ".jpg":
return true;
case ".jpeg":
return true;
case ".png":
return true;
case ".bmp":
return true;
default:
return false;
}
}
protected void btnUpload_Click(object sender, EventArgs e)
{
if (fileupload.HasFile)
{
if (fileupload.PostedFile.ContentLength < 50000)
{
if (CheckFileType(fileupload.FileName))
{
String filepath = "FolderName/" + fileupload.FileName;
fileupload.SaveAs(MapPath(filepath));
qry = "update emp_detail set img='" + filepath.ToString() + "' where emp_id='" + Session["emp_id"].ToString() + "' ";
conn.Open();
SqlCommand cmd = new SqlCommand(qry, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
else
{
lblmsg.Text = "Only jpg, jpeg, png, gif & bmp Images are Allowed";
}
}
else
{
lblmsg.Text = "File size Exceed limit 100KB";
}
}
}