MySQL Forums
Forum List  »  PHP

Re: add picture to MySQL database
Posted by: adam island
Date: January 13, 2009 03:06PM

there is no way to actually add the image to the database.

what you have to do is have a table that saves the image names. your php script will upload the file to a specified folder and add the record with the file name to the database.

so you will need something like this to add an image

$IMAGE_PATH="/path/to/the/image/"
$IMAGE_URL= "http://www.website.com/image/";;

upload the image to
$IMAGE_PATH.$file_name

then query the $file_name for the image that you want to display
<img src='<? echo $IMAGE_URL.$file_name; ?>'>

do a google search for php file uploads. there are plenty of examples. the example may not include database inserts, but after the file is successfully uploaded, do a query something like this
"insert into images (file_name) values ('$file_name')";

that should be enough info to get you going

Options: ReplyQuote


Subject
Written By
Posted
January 12, 2009 11:24AM
Re: add picture to MySQL database
January 13, 2009 03:06PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.