Solved

upload image and store it in the database

  • 1 March 2021
  • 7 replies
  • 312 views

Userlevel 3
Badge +5

I'd like to add an image upload column to my table and have these images stored in the database.

How do I create something like this?

What columns & domains do I have to include, etc.?

icon

Best answer by Mark Jongeling 1 March 2021, 14:42

View original

7 replies

Userlevel 7
Badge +23

Hi Roy,

Couple of columns are needed, one being the upload column and one being the blob (data column).

In this example,

  • company_logo_blob is the upload column and will display the uploaded icon/picture. The value in the database is the name of the file.
  • company_logo_blob_data is the varbinary(max) column that will store the varbinary data of the uploaded icon/picture.
  • Domain Blob_upload as domain, can be nvarchar(2048)
  • Domain Blob_data as varbinary(max)

 

Userlevel 3
Badge +5

Thanks Mark,

Is there also a way to have a larger image than a small icon? Let's say about 5cm x 5cm?

Userlevel 7
Badge +23

The original dimensions will be kept if possible, otherwise it will get reduced in size. Uploaded pictures won't be enlarged.

Icon (small)
Logo (big)

 

Userlevel 3
Badge +5

I see. Setting the Field width (px) and the Field height in positions will do the trick.

Userlevel 3
Badge +8

The original dimensions will be kept if possible, otherwise it will get reduced in size. Uploaded pictures won't be enlarged.

Icon (small)
Logo (big)

 

Hi @Mark Jongeling ,

Can you tell me a bit more about the shrinkage process when reducing the original size? I’ve got this question handed to me since we encountered ‘extremely’ large pictures which significantly reduce performance on the information system.

Can you shed a light on the conditions when it gets reduced, maybe what kind of algorithm you may be using and if I can adjust the conditions when and on what types of upload this can be applied upon? And is this applicable on all the GUI platforms?

Userlevel 6
Badge +16

Are you referring to size as in file size in bytes? When uploading the original file size is maintained in the database. The preview element will scale the picture according to the aspect ratio's but this will not impact the actual file size on the database. 

Userlevel 3
Badge +8

Are you referring to size as in file size in bytes? When uploading the original file size is maintained in the database. The preview element will scale the picture according to the aspect ratio's but this will not impact the actual file size on the database. 

Thanks - I was indeed referring to the actual size in bytes - this is something we’ve noticed we would like to get resized for certain binaries (i.e. pictures and videos). Which as for example is something that whatsapp,facebook,imgur,google does/can do when uploading a fresh photo or video you’ve taken/shot. 

Reply