I have upload a file with file upload control on specific location. but i want to agian upload file on same location by file upload control. but I am getting a error.
"The SaveAs method is configured to require a rooted path, and the path '~/Image/Work/Health/2013-11-29_01-31-53-637PM/img7.jpg' is not rooted."
Please help me

Sanjeeb LenkaPosted Dec 2, 2013, 1:18 AM
imgupload_Image.PostedFile.SaveAs(Server.MapPath("~/Image/Work/" + path[0] + "//" + path[1] + "//") + fileName);
Louis CarlosPosted Dec 10, 2013, 1:54 AM
Stephen RajPosted Dec 9, 2013, 5:37 AM
Nitin BhardwajPosted Dec 2, 2013, 2:04 AM
Nitin BhardwajPosted Dec 2, 2013, 1:58 AM
Sanjeeb LenkaPosted Dec 2, 2013, 1:53 AM
string s=Server.MapPath("~/Image/Work/" + path[0] + "//" + path[1] + "//") + fileName;
Nitin BhardwajPosted Dec 2, 2013, 1:50 AM
Could not find a part of the path...
But path is correct.
Nitin BhardwajPosted Dec 2, 2013, 1:01 AM
Sanjeeb LenkaPosted Dec 2, 2013, 12:59 AM
Nitin BhardwajPosted Dec 2, 2013, 12:50 AM
Sanjeeb LenkaPosted Dec 2, 2013, 12:47 AM
Nitin BhardwajPosted Dec 2, 2013, 12:35 AM
if (type == 'I')
{
if (imgupload_Image.HasFile)
{
string fileName = Path.GetFileName(imgupload_Image.PostedFile.FileName);
var dirName = string.Format("{0:yyyy-MM-dd_hh-mm-ss-ffftt}", DateTime.Now);
Directory.CreateDirectory(Server.MapPath("~/Images/Work/") + ddl_category.SelectedItem.Text);
Directory.CreateDirectory(Server.MapPath("~/Images/Work/" + ddl_category.SelectedItem.Text + "//") + dirName);
string ImagePath = Path.Combine(Server.MapPath("~/Images/Work/") + ddl_category.SelectedItem.Text + "/" + dirName);
if (Directory.Exists(ImagePath))
{
imgupload_Image.PostedFile.SaveAs(ImagePath + "/" + fileName);
portifolio.Type = "I";
portifolio.ImageName = ddl_category.SelectedItem.Text + "/" + dirName + "/" + fileName;
}
}
}
else
{
string[] path = ViewState["ImageFullPath"].ToString().Split('/');
portifolio.PortifolioID = int.Parse(Request.QueryString["portifolioid"].ToString());
portifolio.Type = "U";
if (imgupload_Image.HasFile)
{
//string filename = Path.GetFileName(imgupload_Image.FileName);
string fileName = Path.GetFileName(imgupload_Image.PostedFile.FileName);
imgupload_Image.PostedFile.SaveAs("~/Image/Work/" + path[0] + "/" +path[1]+"/"+ fileName);
portifolio.ImageName=path[0].ToString()+"/"+path[1].ToString()+"/"+ fileName;
}
Sanjeeb LenkaPosted Dec 2, 2013, 12:32 AM