我正在使用<asp:FileUpload />
上传文件(图片),在代码后端中,我使用UploadedFile.SaveAs("C://Path...")
将图像保存在服务器上。
这是我的完整代码:
protected void btnAddImage_OnClick(object sender, ImageClickEventArgs e)
{
//_fuImage is the ID of the <asp:FileUpload />
_fuImage.SaveAs(Server.MapPath(fullPath));
}
问题在于它似乎降低了质量。以下是一些例子:左侧的图像是我要上传的,右侧的图像是上传到服务器上的。
感谢Ashigore使其工作。
byte[] imageBytes = _fuImage.FileBytes;
File.WriteAllBytes(Server.MapPath(fullPath), imageBytes);
我已将字节存储在一个变量中,并将原始字节保存为图像文件上传到服务器。
<img width="x" />
? - Steven V