hi,
i am using this code to upload file in my directory in my website, the problem is now i am moving the images folder on sub domain so how can i give root path like abc.com/dynamicimage path to file to upload instead of ~/dynamicimage
here is my existing code
protected void Upload(object sender, EventArgs e)
{
//if (GridView1.Rows.Count > 0)
//{
// Label7.Visible = true;
//}
// Upload Original Image Here
string uploadFileName = "";
string uploadFilePath = "";
if (FileUpload1.HasFile)
{
string ext = Path.GetExtension(FileUpload1.FileName).ToLower();
if (ext == ".jpg" || ext == ".jpeg" || ext == ".gif" || ext == ".png")
{
System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
int height = img.Height;
int width = img.Width;
decimal size = Math.Round(((decimal)FileUpload1.PostedFile.ContentLength / (decimal)1024), 2);
//if (height != 600 && width != 560)
//{
// Label2.Visible = true;
// Label2.Text = "Image dimension should be height = 600 && width = 560";
//}
//else
//{
uploadFileName = Guid.NewGuid().ToString() + ext;
uploadFilePath = Path.Combine(Server.MapPath("~/DynamicImage"), uploadFileName);
try
{
FileUpload1.SaveAs(uploadFilePath);
Image1.ImageUrl = "~/DynamicImage/" + uploadFileName;
}
catch (Exception ex)
{
Label2.Text = ex.Message;
}
//}
}
else
{
Label2.Text = "Only .jpg allowed";
}
}
}