Images in Databases - what is the best way?

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Images in Databases - what is the best way?

    Hi,

    Really just looking at some advice here. What is the best, most efficient,
    way to store images?
    The way I've worked so far is to store images in a directory on a server,
    and to use a database to store the image file name:

    ProductID - 1
    Name - T-shirt
    Image - tshirt.jpg

    I then use a little bit of code to display this on a site:
    <img src="imagefolder/<%=(rsRecordset.Fields.Item("Image").Value)%>">

    Is this the best way to do this?
    Is there any benefit in storing the image file within the database?
    Will this not massively increase the database size, thus increasing the load
    on it when users are browsing a site?

    Also, I am using ASPUpload to allow clients to upload images directly into
    their web site image folder.
    They are then having to use an INSERT form to insert the image name
    (tshirt.jpg) into one of the DB table fields.

    I am trying to reduce the number of steps required by a user in order to
    upload an image.

    Thanks for any advice offered.
    Regards
    nath.


    Nathon Jones Guest

  2. Similar Questions and Discussions

    1. scrolling images/slider NOT motion images PLEASE REPLY someone
      i want scrolling images...... like scroll bar with text but scroll bar with images...i dont it as in motion pictures....IF no one knows wot i mean...
    2. Displaying Images from Databases on ASP Page
      have been searching for two complete days now on how to display images from a database on the webpage using ASP. I found a script giving some...
    3. Federated Databases, joins across databases etc
      Greetings, I want to do a join between 2 tables on 2 different db2 databases on the same server. I assume that I have to use federated databases. I...
    4. [PHP] images in databases & Flash via PHP
      Saving Images in MySQL http://www.weberdev.com/ViewArticle.php3?ArticleID=3 Sincerely berber Visit http://www.weberdev.com/ Today!!! To...
    5. images in databases & Flash via PHP
      I was wondering - are there any good tutorials/examples of serving & updating images from a mySQL database via PHP? I assume this is possible, but...
  3. #2

    Default Re: Images in Databases - what is the best way?

    On 21 Apr 2005 in macromedia.dreamweaver.appdev, Nathon Jones wrote:
    > Is this the best way to do this?
    Yup.
    > Is there any benefit in storing the image file within the database?
    Not that I've ever seen.
    > Will this not massively increase the database size, thus increasing
    > the load on it when users are browsing a site?
    If you're using an Access database, it's bloated already anyway...
    > Also, I am using ASPUpload to allow clients to upload images
    > directly into their web site image folder.
    > They are then having to use an INSERT form to insert the image name
    > (tshirt.jpg) into one of the DB table fields.
    > I am trying to reduce the number of steps required by a user in
    > order to upload an image.
    Just set up the form with both the image and description fields, and
    process them at the same time.

    <form action="processmyfile.asp" method="post" enctype="multipart/form-data" name="form1">
    <p><input type="file" name="file"></p>
    <p><input type="text" name="description"></p>
    </form>

    --
    Joe Makowiec
    [url]http://makowiec.net/[/url]
    Email: [url]http://makowiec.net/email.php[/url]
    Joe Makowiec Guest

  4. #3

    Default Re: Images in Databases - what is the best way?

    Thanks Joe.
    That is very re-assuring! :)

    With regard the ASPUpload you wrote:

    Just set up the form with both the image and description fields, and process
    them at the same time.

    <form action="processmyfile.asp" method="post" enctype="multipart/form-data"
    name="form1">
    <p><input type="file" name="file"></p>
    <p><input type="text" name="description"></p>
    </form>

    But when I upload the image from, lets say, my Desktop (like a client would
    probably do), the ASPUpload text box has:
    C:\Documents and Settings\User\Local Settings\Desktop\tshirt.jpg (not quite
    that, but you get my drift!)

    How do I get it to strip everything, but the file name, out?

    Also, why is the image file field type="file"...surely it should just be
    text because it should just contain "tshirt.jpg"?

    The very nice people at UltraSuite are looking into this for me at the
    moment, so there may well be an extension that helps us novices out soon.
    Thanks for your advice...much appreciated.

    Nath.

    "Joe Makowiec" <makowiec@invalid.invalid> wrote in message
    news:Xns963F5A5D5CAD2makowiecatnycapdotrE@216.104. 212.96...
    > On 21 Apr 2005 in macromedia.dreamweaver.appdev, Nathon Jones wrote:
    >
    >> Is this the best way to do this?
    >
    > Yup.
    >
    >> Is there any benefit in storing the image file within the database?
    >
    > Not that I've ever seen.
    >
    >> Will this not massively increase the database size, thus increasing
    >> the load on it when users are browsing a site?
    >
    > If you're using an Access database, it's bloated already anyway...
    >
    >> Also, I am using ASPUpload to allow clients to upload images
    >> directly into their web site image folder.
    >> They are then having to use an INSERT form to insert the image name
    >> (tshirt.jpg) into one of the DB table fields.
    >> I am trying to reduce the number of steps required by a user in
    >> order to upload an image.
    >
    > Just set up the form with both the image and description fields, and
    > process them at the same time.
    >
    > <form action="processmyfile.asp" method="post"
    > enctype="multipart/form-data" name="form1">
    > <p><input type="file" name="file"></p>
    > <p><input type="text" name="description"></p>
    > </form>
    >
    > --
    > Joe Makowiec
    > [url]http://makowiec.net/[/url]
    > Email: [url]http://makowiec.net/email.php[/url]

    Nathon Jones Guest

  5. #4

    Default Re: Images in Databases - what is the best way?

    On Thu 21 Apr 2005 09:10:42a, Nathon Jones wrote in
    macromedia.dreamweaver.appdev:
    > But when I upload the image from, lets say, my Desktop (like a client
    > would probably do), the ASPUpload text box has:
    > C:\Documents and Settings\User\Local Settings\Desktop\tshirt.jpg (not
    > quite that, but you get my drift!)
    >
    > How do I get it to strip everything, but the file name, out?
    >
    > Also, why is the image file field type="file"...surely it should just
    > be text because it should just contain "tshirt.jpg"?
    There are several parts to the process:
    - find the file on the client machine
    - upload the file to the host
    - save the file on the host
    - save the (uploaded) filename in the database on the host
    - save the file description in the database on the host

    I'm not familiar with ASPUpload, but its function is going to be, I assume,
    to take care of the second and third of those items. You, the web
    designer, have to do the others. The first you do by way of having an
    <input type="file"...> in your upload form. The last two you do in the
    script which processes the input from the form.

    Note: for security reasons, you don't necessarily want to use the name of
    the file which was uploaded as the name of the file you save on the server.
    Joe Makowiec Guest

  6. #5

    Default Re: Images in Databases - what is the best way?

    On Thu 21 Apr 2005 05:07:52p, Joe Makowiec wrote in
    macromedia.dreamweaver.appdev:
    > Note: for security reasons, you don't necessarily want to use the name
    > of the file which was uploaded as the name of the file you save on the
    > server.
    Added note: this also has the advantage of avoiding filename collisions.
    Say you uploaded a file called bottle.jpg', because it was of a bottle.
    Because this site is devoted to collectors of bottles, I, too want to
    upload a picture from my collection. Human ingenuity being what it is, my
    file is also called, oddly enough, 'bottle.jpg'. This creates problems
    when you go to save the file.

    If you have the upload routine create a filename based on, say, the date
    and time that the file was uploaded, odds are very good that you'll never
    have a filename collision. You could also save the original filename in
    the record, so that the record could be searced by original filename if you
    wanted.
    Joe Makowiec Guest

  7. #6

    Default Re: Images in Databases - what is the best way?

    Nathon Jones wrote:
    > Thanks Joe.
    > That is very re-assuring! :)
    >
    > With regard the ASPUpload you wrote:
    >
    > Just set up the form with both the image and description fields, and process
    > them at the same time.
    >
    > <form action="processmyfile.asp" method="post" enctype="multipart/form-data"
    > name="form1">
    > <p><input type="file" name="file"></p>
    > <p><input type="text" name="description"></p>
    > </form>
    >
    > But when I upload the image from, lets say, my Desktop (like a client would
    > probably do), the ASPUpload text box has:
    > C:\Documents and Settings\User\Local Settings\Desktop\tshirt.jpg (not quite
    > that, but you get my drift!)
    >
    > How do I get it to strip everything, but the file name, out?
    in the page processmyfile.asp you can't use the Request.Form collection
    to access elements in the form so, you must use 2 collections provided
    by ASPUpload. to recover the file name:

    Upload.Files("file").FileName

    or the entire path:

    Upload.Files("file").Path

    note that "file" is the name you assigned to the <INPUT type="file" field

    i'm not sure now but i'd swear ASPUpload can generate unique file names,
    check the manual
    > Also, why is the image file field type="file"...surely it should just be
    > text because it should just contain "tshirt.jpg"?
    type="file" is a special field that shows, besides the text box, the
    browse button to allow the user to select the file without having to
    type the entire path

    Manuel Socarras Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139