Jason Bentley wrote:
Nato, post your code. This type of problem is hard to troubleshoot
without seeing the suspect code.
Jason Bentley http://geekswithblogs.net/jbentley
Its not pretty, but here it is...
If Not (myFile.PostedF ile Is Nothing) Then
Dim objImage As System.Drawing. Image
Dim intHeight, intWidth As Integer
Dim strFilename As String = Path.GetFileNam e(myFile.Posted File.Filename)
Dim strPath As String = Server.MapPath( "/images/")
'ensure image is jpg format
If LCase(Right(str Filename,3)) = "jpg" Or LCase(Right(str Filename,3)) =
"peg" Then
Try
'ensure image is under 1 mb
If myFile.PostedFi le.ContentLengt h < 1000000 Then '1MB
'save original image
myFile.PostedFi le.SaveAs(strPa th & strFilename)
objImage.FromFi le(".." & strPath & strFilename)
If objImage.Height > objImage.Width Then
' Work out a proportionate width from height
intWidth = objImage.Width / (objImage.Heigh t / intHeight)
Else
'work out a proportionate height from width
intHeight = objImage.Height / (objImage.Width / intWidth)
End If
Dim strPathTN As String = strPath & "tn_" & strFilename
objImage.GetThu mbnailImage(int Width, intHeight, Nothing, System.IntPtr.Z ero)
objImage.Save(s trPathTN, ImageFormat.Jpe g)
objImage.Dispos e()
'Message.Text = "Image Added Successfully."
img_staff.Image URL = "../images/tn_" & strFilename
Else
'notify user image is too large
'Message.Text = "Image is too large"
End If
Catch exc As Exception
Message.Text = exc.ToString()
End Try
Else
'notify user that image is not jpeg format
'Message.Text = "Please ensure image is jpg format."
Exit Sub
End If
End If
End Sub
Thanks,
Nathan