SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2013
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy How to upload an image into db?

    How to upload an image into database?

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,435
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    If you use advanced search > Titles only and search for "photo database" there are 140 results.

    Also you could do with suppling more information like are you putting the path into the database or the image; are you resizing etc. as well; are you using a form and if so how many images at once?

  3. #3
    SitePoint Addict bronze trophy vectorialpx's Avatar
    Join Date
    Dec 2012
    Location
    Bucharest
    Posts
    247
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Another search
    https://www.google.com/search?q=php+images+into+mysql

    However, long story short: you need a [blob] field, add into it a base64_encode of file_get_contents( image ) and for display, use header('Content-type: image/jpg'); (or whatever)

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    51
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Or even better, do NOT store images in the database. Store them on disk, and put only image file name in the database. Unless you have a homework or something like that where you need to practice such things...

  5. #5
    SitePoint Addict bronze trophy vectorialpx's Avatar
    Join Date
    Dec 2012
    Location
    Bucharest
    Posts
    247
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Avram View Post
    Or even better, do NOT store images in the database.
    True, this is a bad practice for so many reasons - first two, if you need examples: scalability and performance.

  6. #6
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can upload in to directory and save the path in a field and then fetch data display it.


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
  •