图像未保存到Web服务器上的文件夹但保存在localhost中
问题描述:
当尝试使用fileupload控件保存在localhost机器中时将图像保存在文件夹中,但是从其他计算机访问此URL时它无法显示运行时错误。
如果我运行此URL网络服务器,然后这工作,但从外面不工作,我给了IUser,本地服务,网络服务等的全部权利...
以下是我的代码>
When trying to save the Image in the folder using fileupload control saving in localhost machine,but accessing this URL from other machines it is not working showing Run time error.
if i run this URL from webserver then this works,but from outside not working, i gave full rights to IUser,Local Service,Network Service etc...
Below is my code
if (FileUploadSignature.HasFile)
{
string ImgExt = System.IO.Path.GetExtension(FileUploadSignature.PostedFile.FileName).ToUpper();
if (ImgExt == ".PNG" || ImgExt == ".BMP" || ImgExt == ".GIF" || ImgExt == ".JPG" || ImgExt == ".JPEG")
{
if (System.IO.File.Exists(Server.MapPath(@"~\Signature\" + txtEmployeeID.Value.Trim() + ".Jpeg")))
{
System.IO.File.Delete(Server.MapPath(@"~\Signature\" + txtEmployeeID.Value.Trim() + ".Jpeg"));
}
System.Drawing.Image image = System.Drawing.Image.FromFile(FileUploadSignature.PostedFile.FileName);
int thumbWidth = image.Width;
if (thumbWidth > 100)
{
thumbWidth = 100;
}
else
{
thumbWidth = image.Width;
}
int srcWidth = image.Width;
int srcHeight = image.Height;
Decimal sizeRatio = ((Decimal)srcHeight / srcWidth);
int thumbHeight = Decimal.ToInt32(sizeRatio * thumbWidth);
Bitmap bmp = new Bitmap(thumbWidth, thumbHeight);
System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bmp);
gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
System.Drawing.Rectangle rectDestination = new System.Drawing.Rectangle(0, 0, thumbWidth, thumbHeight);
gr.DrawImage(image, rectDestination, 0, 0, srcWidth, srcHeight, GraphicsUnit.Pixel);
bmp.Save(Server.MapPath(@"~\Signature\"+txtEmployeeID.Value.Trim()+".Jpeg"), System.Drawing.Imaging.ImageFormat.Jpeg);
bmp.Dispose();
ShowMessage("Saved Sucessfully");
}
else
{
ShowMessage("Invalid Picture Format/Type");
return;
}
}
else
{
ShowMessage("Please select the image then click save");
return;
}
答