SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2003
    Location
    uk
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to insert an image in the database...

    I m trying to set up a form so that a user can isert a gif or jpeg image into a table in the database.

    1) Can you please show me how to create a table in the database so that it accepts the images

    2) I need to know how to actually browse to an image in hard drive and then insert it in the table


    Thanks in advance

  2. #2
    Non-Member Icheb's Avatar
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    1,474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your best bet would be to only store information about the picture in the database and store the actual picture in the filesystem.

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2003
    Location
    uk
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but the issue is that users will have to browse to a picture in their system then store it in the database so that it can be accessed by anyone within the intranet

  4. #4
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Icheb suggestion will allow you to do that. The user uploads an image to a directory on the web server that you specify, and then you store the path/image name in the database. When a user needs to view the image you just pull out the path and image name and display the image.

  5. #5
    SitePoint Evangelist
    Join Date
    Dec 2003
    Location
    uk
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The reason i need to store the image in the database is for security reasons.

    sql="INSERT INTO userdetails (reg,name,dob,tel,photo) "
    sql=sql & " VALUES "

    sql=sql & "('" & Request.form("reg") & "',"

    sql=sql & "'" & Request.Form("name") & "',"
    sql=sql & "'" & Request.Form("dob") & "',"
    sql=sql & "'" & Request.Form("tel") & "',"
    sql=sql & "'" & Request.Form("photo") & "')"

    what attribute shall i assign to photo whaen i create table userdetails?


    secondly, if i create a code that allows users to upload an image in the webserver, then how can i associate the path of the image with that particular user details stored in the table? not sure how to implement this.

    Thanks

  6. #6
    SitePoint Member
    Join Date
    Oct 2004
    Location
    China
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please see the attach files
    i think it can slove you problem
    Attached Files Attached Files

  7. #7
    Non-Member Icheb's Avatar
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    1,474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you don't want people to see the actual URL to the image, create a script that calls the image and then sends it to the browser, like imageviewer.asp?image=bla . If you only want logged in people or whatever to have access to a particular image, then don't let them view it.
    Binary data should NOT be in a database, because there is nothing you can do with an image in a database that an able programmer can't do with an image in the filesystem.


Bookmarks

Posting Permissions

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