Hi everyone,
i need script about inserting images into mysql database useing php...
can anyone reply to me...
thanks in advance..
kushal
how to insert images into mysql using php
Moderator: General Moderators
-
kushaljutta
- Forum Commoner
- Posts: 50
- Joined: Fri Dec 26, 2008 11:05 am
Re: how to insert images into mysql using php
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.
Then, to convert the blob back to an image, you can use imagecreatefromstring.
Re: how to insert images into mysql using php
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.
Re: how to insert images into mysql using php
Totally agreed.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.
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