Click here to Skip to main content
15,888,271 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
when i want save image from fileupload Face with problem .
my code is :

C#
string filename = "nopic.gif";


       if (FileUpload1.HasFile)
       {


               filename = FileUpload1.FileName;

               Bitmap bmp = new Bitmap(FileUpload1.FileContent);
               System.Drawing.Image img = bmp;

               ResizeImage.ImageResize imgRe = new ResizeImage.ImageResize();
               img = imgRe.Resize(img, 85, 113);




               //string directory = Server.MapPath(@"~\admin\teacherPic\\");
               string directory = Server.MapPath("./all_images/foroshgahImages/");
               img.Save(directory + filename);

       }


hint: this code run Other places.In this location my webPage content a updatePanel.
Posted
Updated 9-Sep-11 19:57pm
v2
Comments
OriginalGriff 10-Sep-11 2:00am    
What line causes the error?
mehdi smm 10-Sep-11 2:03am    
problem in line:img.save(directory+filename);

"problem in line:img.save(directory+filename);"

In which case, I would suspect the problem is either the line above:
C#
string directory = Server.MapPath("./all_images/foroshgahImages/");
Which may be returning an invalid path, or that the directory write permissions are not set correctly. Check the directory value before you save the file.

Look and see if you get any useful information in the exception and inner exception by enclosing it in a try / catch - that may help isolate it.
 
Share this answer
 
Comments
mehdi smm 10-Sep-11 2:14am    
i use a try/catch but my problem not solved.
OriginalGriff 10-Sep-11 2:18am    
I'm not expecting try/catch to SOLVE your problem. It should give you more information to help YOU solve it.
mehdi smm 10-Sep-11 2:29am    
it return previous error .
I find my error
error is this :
C#
Bitmap bmp = new Bitmap(FileUpload1.FileContent);
                System.Drawing.Image img = bmp;
 
                ResizeImage.ImageResize imgRe = new ResizeImage.ImageResize();
                img = imgRe.Resize(img, 85, 113);

now how resize my image
 
Share this answer
 
v2
Comments
Richard MacCutchan 10-Sep-11 5:13am    
What are the values of directory and filename and what error do you get?

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



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