Adding images to the database

  • Thread starter Thread starter Earl
  • Start date Start date
E

Earl

Looking for an idea here. I've got a .Net app connecting to SQL2005 where I
allow users to add pictures to the database. But I don't want them adding
gigantic images, so I'm looking for an idea on how to control how big of an
image they might add. I'm not interested in simply saving a pointer to a
file here.
 
varbinary (max) would automatically limit them to 2 GB size, but your best
bet might be to check the size on the client side if you want to limit them
to say 10 MB or something. If you send it to the server first, someone
might have just spent all that time uploading a 100 MB file only to have it
error on them. That's a waste of time and bandwidth. If you want to ensure
that, for instance, your developers can't work their way around the system
and bypass the client app to insert larger files you might look into
triggers as well.
 
Earl,

the most easiest way is in my idea to use the thumbnail.

In this sample is that used.
Dim fo As New OpenFileDialog
If fo.ShowDialog = DialogResult.OK Then
PictureBox1.Image = PictureBox1.Image.FromFile(fo.FileName)
Dim Thumbnail As System.drawing.Image = _
PictureBox1.Image.GetThumbnailImage(32, 32, Nothing, New IntPtr)
PictureBox2.Image = Thumbnail
End If


I hope this helps,

Cor
 
Thanks to all, Mike, Mikael and Cor. Looks like I'm going to resize on the
client side using the new Width and Height. I can certainly see uses for
thumbnails though.
 
Back
Top