If the error is memory related, then it's likely because the image data is being disposed with the Stream object when this method exits. Try capturing it into an intermediate Bitmap object and assigning that Bitmap to the PictureBox image property instead.
Here's a link that might help:
Saving Image to MemoryStream- Generic GDI+ Error
Ultimately, this is referenced as an information source:
http://msdn.microsoft.com/en-us/library/z7ha67kw
Edit:
I don't know what type "upload1" is or its scope, but assuming it's a local object, I wonder about this approach (this would be a method you'd call to retrieve the Byte[] or the Image):
protected void Button2_Click(object sender, EventArgs e)
{
//upload1.SaveAs(Server.MapPath("~/imgs/" + upload1.FileName).ToString());
//pbficheiro.ImageUrl = @"~/imgs/" + upload1.FileName;
Byte[] ba = new BinaryReader(upload1.PostedFile.InputStream).ReadBytes((Int32)upload1.PostedFile.InputStream.Length);
using (MemoryStream ms = new MemoryStream(ba, false))
{
System.Drawing.Image imgTmp = System.Drawing.Image.FromStream(ms);
Bitmap bm = new Bitmap(imgTmp.Width, imgTmp.Height);
Graphics g = Graphics.FromImage(bm);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
Rectangle rect = new Rectangle(0, 0, imgTmp.Width, imgTmp.Height);
g.DrawImage(imgTmp, rect, 0, 0, imgTmp.Width, imgTmp.Height, GraphicsUnit.Pixel);
bm.Save(Server.MapPath("~/imgs/" + upload1.FileName).ToString());
pbficheiro.ImageUrl = @"~/imgs/" + upload1.FileName;
}
}