I have applied the recommended solution for the GDI+ error from here:
A generic error occurred in GDI+, JPEG Image to MemoryStream
I still does not work for jpeg and jpg files, but works fine for all png
See my actual code below:
Dim fl = uploader.PostedFile.FileName.ToLower
If fl.EndsWith(".png") OrElse fl.EndsWith(".jpeg") OrElse fl.EndsWith(".jpg") Then
Using ms = New MemoryStream(uploader.FileBytes)
Using i = Drawing.Image.FromStream(ms)
i.Save(ms, If(fl.EndsWith(".png"), System.Drawing.Imaging.ImageFormat.Png, System.Drawing.Imaging.ImageFormat.Jpeg))
Dim sig = Convert.ToBase64String(ms.ToArray())
Dim code = Trim(txtStaff.Text).PadLeft("00000000")
DB.rw_signature_save(code, sig)
End Using
End Using
BuildSignatureList()
statusBox.Attributes("class") = "notification success"
statusBox.InnerHtml = "Signature updated succesfully"
Else
statusBox.Attributes("class") = "notification warning"
statusBox.InnerHtml = "Only <b>Image</b> ( <font color='green'>.png, .jpg </font> ) files allowed."
End If
Please is there any other solution to this besides the one linked to above? Thanks.