Upload Image into Target folder in Web application
===This C# Code is for Up load File in to specific Folder===
using System.IO; //Name Space is used
string image;
image = System.IO.Path.GetExtension(FileUpload2.FileName);
if (image == ".jpg" || image == ".jpeg" || image == ".JPG" || image == ".JPEG" || image == ".gif" || image == ".GIF")
{
FileUpload2.SaveAs(MapPath("~/Item_Picture/" + Add_Id.ToString() + ".jpg"));
string fn = "~/Item_Picture/" + System.IO.Path.GetFileName("~/Item_Picture/" + Add_Id.ToString() + ".jpg"); //Item_Picture is a folder in root
try
{
con.insert_data("insert into tbl_item values(" + Add_Id + ",'" + fn + "','" + txt_details.Text + "')");
//Image1.ImageUrl = fn;
txt_details.Text = "";
gridbing();
RMG.Functions.MsgBox("Added Successfully!!!");
}
catch (Exception ex)
{
}
=== HOPE IT HELP U -Raj
0 comments: