大家好 当我想从fileupload保存图像时出现问题. 我的代码是:
hi all when i want save image from fileupload Face with problem . my code is :
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); }提示:此代码在其他位置运行.在此位置,我的网页上包含一个updatePanel.
hint: this code run Other places.In this location my webPage content a updatePanel.
推荐答案问题所在行:img.save(目录+文件名) ;" 在这种情况下,我会怀疑问题出在上面的那一行: "problem in line:img.save(directory+filename);" In which case, I would suspect the problem is either the line above: string directory = Server.MapPath("./all_images/foroshgahImages/");
可能返回无效路径,或者目录写权限设置不正确.保存文件之前,请检查directory值. 通过将其包含在try/catch中,可以查看并查看是否在异常和内部异常中获得了任何有用的信息,这可能有助于将其隔离.
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.
我发现了我的错误 错误是这样的: I find my error error is this : 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
更多推荐
GDI +中发生通用错误的问题.
发布评论