Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
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;
        }
Posted
Updated 2-Apr-14 21:30pm
v2
Comments
Kornfeld Eliyahu Peter 3-Apr-14 3:31am    
You may have some access denied error, that swallowed somewhere - try to trace it...
Robymon 3-Apr-14 3:45am    
I did give all permissions(Read,Write), eg: IUSR,IIS_,Local Service,Network Service etc...
Kornfeld Eliyahu Peter 3-Apr-14 3:47am    
Can you be specific about the run-time error you mentioned?
Robymon 3-Apr-14 3:50am    
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customerrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customerrors> tag should then have its "mode" attribute set to "Off".
Kornfeld Eliyahu Peter 3-Apr-14 3:52am    
Can you change the web.config to show error also from client?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900