我正在尝试上传图像,当我尝试 image.Save() 时,我收到“通用 GDI+”错误。任何帮助都会很棒。
// This action handles the form POST and the upload
[HttpPost]
public ActionResult Index(HttpPostedFileBase file, string filename)
{
// Verify that the user selected a file
if (file != null && file.ContentLength > 0)
{
string location = "~/Content/Images/Specials/" + "rttest" + ".jpg";
Bitmap bitmap = new Bitmap(file.InputStream);
Image image = (Image)bitmap;
image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
image.Save(location);
}
// redirect back to the index action to show the form once again
return RedirectToAction("Index");
}