how to insert images into mysql using php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kushaljutta
Forum Commoner
Posts: 50
Joined: Fri Dec 26, 2008 11:05 am

how to insert images into mysql using php

Post by kushaljutta »

Hi everyone,

i need script about inserting images into mysql database useing php...

can anyone reply to me...

thanks in advance..

kushal
Andrewrun
Forum Newbie
Posts: 7
Joined: Fri Dec 26, 2008 12:46 pm

Re: how to insert images into mysql using php

Post by Andrewrun »

I think you can read the image file using file_get_contents and then store it in a blob field in the database.

Then, to convert the blob back to an image, you can use imagecreatefromstring.
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: how to insert images into mysql using php

Post by watson516 »

You might want to think about just inserting a 'link' to the image and upload the image into a dir on the web server. When you need the image, use the link in an img tag or background or whatever you need. If you have to transfer the db to another server, you'll just have to copy over the image directory.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: how to insert images into mysql using php

Post by requinix »

watson516 wrote:You might want to think about just inserting a 'link' to the image and upload the image into a dir on the web server. When you need the image, use the link in an img tag or background or whatever you need. If you have to transfer the db to another server, you'll just have to copy over the image directory.
Totally agreed.

Putting images into a database may look cool and all but it's not worth it. Puts an even heavier load on the database because it's serving mere images too.
kushaljutta
Forum Commoner
Posts: 50
Joined: Fri Dec 26, 2008 11:05 am

Re: how to insert images into mysql using php

Post by kushaljutta »

thanks for ur suggestion....


just introduce urself with me

kushal.jutta@gmail.com

mail me...
Post Reply