By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 2,226 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

how to store the image in database using php

P: 6
hello guys,
i need your help...
i face problem in storing image in database...
can any one send me the complete coding of storing image in database...
please i need ur help...
plz try to send me complete coding of stroing image file in php...

thanks and regards
Vivek Goyal
Sep 17 '07 #1
Share this Question
Share on Google+
3 Replies


gregerly
Expert 100+
P: 192
hello guys,
i need your help...
i face problem in storing image in database...
can any one send me the complete coding of storing image in database...
please i need ur help...
plz try to send me complete coding of stroing image file in php...

thanks and regards
Vivek Goyal
Hi vivekgoyal,

We are here to help you when you have questions with projects you might be working on, not to do your projects for you. I'de be more than willing to help you if you have some code you want some help on. Post what you have so far and we can go from there.

Thanks,

greg
Sep 17 '07 #2

P: 9
hello guys,
i need your help...
i face problem in storing image in database...
can any one send me the complete coding of storing image in database...
please i need ur help...
plz try to send me complete coding of stroing image file in php...

thanks and regards
Vivek Goyal
I wouldn't ask for code, its better to understand what your are doing yourself. Plus it may not be compatabile with what you already have

Firstly i wouldn't store the images in a db, i would store the path to the image in the db and then retreive when you need it. i think you'll find thats simpler.
Sep 17 '07 #3

100+
P: 105
Hi Vivek

It really very easy: all you do is prepare a a DB slot(long blob) and store in it your image handle. The code below assumes you know how to upload using HTML

[php]


$handle = fopen($_FILE['file']['tmp_name'], "r");

$sql = "INSERT INTO image (image, .... ......) ";
$sql .= "VALUES ('$handle' .. .....)";

//then insert and WALLA!!! there you have it

[/php]


But I wouldnt recomment this method for many reasons. Instead you should store the image as a file and put the NAME of the image into the DB

This might help you, as it has complete example codes

http://www.codewalkers.com/c/a/Datab...s-in-Database/
Sep 17 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.