Hi
I have a host that name is one of my domain names and I create other website domain in my host (I mean I have 2 websites in my host) and I define file upload control in the page that users can upload their image
Now when I select an image from file upload and click the button to save the image into the host below error occurs
Access to the path 'C:\Inetpub\vhosts\amlakeabdi.ir\digimaster.ir\Image\film\Detail\545.jpg' is denied.
below are codes:
protected void BtnUploadD_Click(object sender, EventArgs e)
{
string newFileName = string.Empty;
int count = 0;
if (fupImgD.HasFile && fupImgD.PostedFile.ContentLength < 10240000)
{
string ext = Path.GetExtension(fupImgD.PostedFile.FileName);
string[] files = Directory.GetFiles(Server.MapPath("~/Image/film/Detail/"));
string fileName = System.IO.Path.GetFileName(fupImgD.PostedFile.FileName);
if (File.Exists(Server.MapPath("~/Image/film/Detail/") + this.TxtImdb.Text + ext))
{
foreach (string s in files)
{
string filename = string.Empty;
filename = Path.GetFileName(s).Substring(0, Path.GetFileName(s).LastIndexOf("."));
if (filename.Contains("("))
{
filename = filename.Substring(0, filename.LastIndexOf("("));
}
if (filename == this.TxtImdb.Text.Trim())
{
count++;
}
}
newFileName = this.TxtImdb.Text + "(" + count.ToString() + ")" + ext;
this.fupImgD.PostedFile.SaveAs(Server.MapPath("~/Image/film/Detail/") + this.TxtImdb.Text + "(" + count.ToString() + ")" + ext);
}
else
{
newFileName = this.TxtImdb.Text + ext;
this.fupImgD.PostedFile.SaveAs(Server.MapPath("~/Image/film/Detail/") + this.TxtImdb.Text + ext);
}
imgdeleteImgD.Visible = !(BtnPopupD.Visible = false);
Lblimgdetail.Text = newFileName;
Dimage.HRef = "~/Image/film/Detail/" + newFileName;
}
else
{
//uploadImageError.Text = "*حجم فایل شما" + Convert.ToString(fup2.PostedFile.ContentLength / 1024) + "KB می باشد لطفاعکس با حجم کمتر از100 KB آپلود نمایید.";
}
}
I don't know why this happens
can you help me?
best regards
Neda