Most of the time, it's a bad idea to insert large data like pictures into a database, as SQL is not really standardized about how big BLOBs (== binary large objects or something like that) are allowed to become.

I suggest that you create a unique filename for your image and then save the uploaded image on the disk and a link to that image in your database.

If you really really really need to store your images in the database (and your images are all guaranteed to be smaller than 4k, because many databases have problems with larger entries), you will have to encode your images to make them SQL-safe and then store them like any other value. Why making them SQL-safe ? You wouldn't want a user to upload a cleverly crafted image that executes some valid SQL code on your database, for example dumping all password data.

But in general I think it's a better solution to store the files themselves out of the database.

I just saw that you will be using Win32::ODBC to access your database - be prepared for even weirder limits on field size, as now both the ODBC driver and the database impose limits on your data.


In reply to Re: insert GIF into SQLServer by Corion
in thread insert GIF into SQLServer by iic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.