Welcome Guest, Not a member yet? Register   Sign In
Inserting image files into Blob field under Mssql
#1

[eluser]davidino86[/eluser]
hi to everybody,

I've been trying to insert image files into a mssql blob with codeigniter application but i can't work it out to insert it correctly even too read the image(i think because the file is not correctly uploaded)

any one can help me please?
#2

[eluser]mattpointblank[/eluser]
Having never done this with CI I can't help, but I can advise you NOT to store images this way. Files belong in the filesystem and inserting them into the DB has few advantages - it'll slow down pages as you have to complete the query before the image can begin downloading, they won't cache properly if you output them from BLOB, your database size will increase much more than it would for just text, and if you ever need to get them out of the DB and back into files (which you surely will once you realise this method is a bad solution), it's an absolute pain to process.

Save yourself time and find another approach (store files in filesystem and just record the path or filename in the db). If you don't believe me, google it - the general consensus seems to be avoid storing images in BLOBs.
#3

[eluser]davidino86[/eluser]
Yes, i think you are right!! the best process is to load the name of the file into DB and store the image into a filesystem's directory and save into a config file the relative path of the uploaded real size images and the path of the thumbnails.

I think that this is the same process of the biggest images sites like istockphoto and flickr, although more complex than my application.
#4

[eluser]davidino86[/eluser]
i got another question for you. what is the best way between load two images (one for the real size and one for the thumbnail) or use an handler for unique big image? if the best way is the second one, exist an handle for the images in Codeigniter?

thank you guys.
#5

[eluser]jedd[/eluser]
The best way (in my opinion (and assuming I've understood your question)) is to generate whatever derivative images you need as soon as the image is introduced into the system.

That is, on image load or discovery - you generate the appropriate cache versions - thumb, medium, huge, raw/original etc - record them in your file system sensibly, and then you can safely refer to them any and everywhere.

Dynamically converting images is expensive in terms of CPU - far more expensive than storage.
#6

[eluser]davidino86[/eluser]
yes you have understood and sorry for my bad english, ok thanks for the answer.
#7

[eluser]Thug_Angel[/eluser]
I came across a very good article regarding saving images to database.
Before you decide yes or no in saving your images to the database I would recomment reading this article then you decide the best method for you.

Proz and conz of saving images to database




Theme © iAndrew 2016 - Forum software by © MyBB