Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

retrieve image

database

  • Please log in to reply
10 replies to this topic

#1 ahmedzoom99

ahmedzoom99

    CC Lurker

  • New Member
  • Pip
  • 4 posts
  • Programming Language:Java, PHP, PL/SQL
  • Learning:JavaScript

Posted 01 October 2012 - 11:30 PM

hi :

how i can retrieve image in my database using phpmyadmin


and there are any method better than phpmyadmin to make my database


thank you for helping me
  • 0

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 02 October 2012 - 07:15 AM

You're going to have an issue with retreiving it, because the image is stored as binary data. PHPmyAdmin really wasn't meant for extracting that binary data, which could be an image, or a PDF, or a Word document. I would write a small PHP app to do that, instead.

As to how to make your database, that depends on the database. MySQL works well with PHPMyAdmin, but if you're using SQL Server or Oracle, then their tools would probably be best. I use SQuirreL SQL Client when working with databases, as it works with any of them quite well.
  • 1

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 VNFox

VNFox

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 648 posts
  • Programming Language:C#, PHP
  • Learning:Assembly

Posted 02 October 2012 - 08:10 AM

I think you need to custom your app a littble ... pull it as binary data and convert it to image. I don't think there is any option in PhpMyAdmin to do this.
  • 0

www.pickmike.com
I don't just develop software. I find solutions to your business needs.


#4 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash

Posted 02 October 2012 - 08:45 AM

I have to ask why you're storing images in a database? Normally, the database will contain a reference to an image, like it's location on the server or web. The overhead of storing and retrieving images from a DB is rather large.
  • 0
My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth

#5 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 02 October 2012 - 11:51 AM

I have to ask why you're storing images in a database? Normally, the database will contain a reference to an image, like it's location on the server or web. The overhead of storing and retrieving images from a DB is rather large.

Storing images in DB can be very good at times. The images is easier to handle in one way, as you don't have to think about unique file names and much more. Also, a hacker which reach the file system don't find the images directly but need to search through the db for it. Also, the images isn't accessible by a url directly so you can build in a security layer in your server side language to prevent misusage etc.
  • 1

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#6 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash

Posted 03 October 2012 - 05:01 AM

If security is a concern, put them in a location that is not accessible by the web server and write a script that handles security and serves up the files. When necessary, I write a httphandler to do just that.

There are many reason against storing images in a DB :

1. If your DB becomes corrupt to the point backups wont fix it, you loose your graphics as well as your data.
2. if there is any chance that you will migrate to a different database platform, your current BLOB format might be incompatible with, or at least a pain to convert to, the new format -- since, like web browsers, each vendor has implemented things with their own slant.
  • 0
My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth

#7 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 03 October 2012 - 05:53 AM

Everything has pros and cons. You have to choose when to use the features and when not to. There is no such thing as the perfect condition for a feature,, and there is no feature that don't have a good occurance when to use it, otherwise it hadn't been created.
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#8 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash

Posted 04 October 2012 - 04:55 AM

My point is that it is frowned upon in the programming world. Of course anyone is free to architect their project as they wish. There are good practices and bad ones. Putting website graphics in a DB is a bad one.
  • 0
My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth

#9 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 04 October 2012 - 03:40 PM

Well, the website graphics shouldn't be in a db, there I agree. But user pictures on a website can absolutely be stored in a db...
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#10 Colanth

Colanth

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 165 posts
  • Location:Fayetteville, NC, USA
  • Programming Language:PHP, (Visual) Basic, JavaScript, Visual Basic .NET, Pascal, Logo, Assembly, VBScript, Others

Posted 14 October 2012 - 05:36 PM

In theory, theory and practice are the same. In practice they're different.

Storing images in DB can be very good at times.

In over 20 years, I've never found one.

The images is easier to handle in one way, as you don't have to think about unique file names and much more.

You never do - that's one thing computers are good at. You just let the computer create a unique name. (PHP even has a GUID function.)

Also, a hacker which reach the file system don't find the images directly but need to search through the db for it.

If the files aren't in your document path, he can't find the files.

Also, the images isn't accessible by a url directly so you can build in a security layer in your server side language to prevent misusage etc.

See above.

The main disadvantage is the terrific overwork you're putting on the database. Get hit by a few thousand requests for 10 images and your database is dying. (Never think that your website isn't going to be visited by thousands of people - doing so gives you a website you can't upgrade easily. Think AOL's or CNN's home page.)

"Designing for crash" usually results in crashes.
  • 0

#11 Barnsite

Barnsite

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 258 posts
  • Location:West Sussex, UK
  • Programming Language:C#, (Visual) Basic, Visual Basic .NET, Transact-SQL, Others
  • Learning:Java

Posted 25 October 2012 - 06:19 AM

I have developed a database where images were required to be stored in the DB not in the file system, but only once. These were photos taken by surveyors.

This was due to the client specifying that the DB needed to be independent of it's environment, i.e. they did not have the control over the file system / folder structures and couldn't ensure that these would not change.

They also wanted all the data to be contained within the database back-up...
  • 0
There are two ways to write error-free programs; only the third one works.





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download