SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist Raining_Curses's Avatar
    Join Date
    May 2005
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Picture for a profile

    Hi all,

    Im looking to be able to have people put pictures into there profiles on my website. Is it possible to store a picture in a MySQL database or do i have to do it some other way?

    Please help me

    Thanks for your help

  2. #2
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Regina, SK
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Yes you can...

    You can store binary data in a table, you'll want to look at the blob column type. Personally, I wouldn't go this route. I've done similar things in the past, and usually what I will do is to store only the location of the image in the database. Instead of storing the actual file in the database, store it in the filesystem. Create a directory that is writeable by the webserver. Use php to handle uploads and such to the directory.

    If you store a file in the database, you're slowing down the page loading time, as well as putting extra load on the server. To display the image, you would need to:

    query the database (probably being done anyways)
    store the image in RAM
    pass the image from the database to php
    pass the image from php to the web server

    Alternately:
    query the database (probably being done anyways)
    pass the file location to php
    pass the file loation to the webserver

    Webservers are meant to handle and display files, let it do the work instead. Its faster, and will allow you site to handle more requests.
    Reduce or eliminate spam on your sites without CAPTHCAs
    - maybe it is possible: http://formantispam.thekerrs.ca/

  3. #3
    SitePoint Evangelist Raining_Curses's Avatar
    Join Date
    May 2005
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, ill give it a try and get back to you
    www.thetrial.staronesw.com
    Check out my online text based rpg (In development!!)


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
  •