Good Day, PHP Members HELP W/DB Images


I am desperately trying to allow the user to put selected images into the database and than view them in the photo gallery. If you know the method please tell me. I have tried for 3 days.

I have in my database table with all other member slots so to say (this)

short_title varchar = 50
mime_ type varchar = 50
file_data Binary = blob

Once the file goes in, it looks like this:
----------------------------
[BLOB - 9 Bytes]

And the short-title enters
-----------------------------

I cannot get the mime type to appear.
-----------------------------

My code looks like this:

<form "method="POST" action="photos.php" name="imagefrm" enctype="multipart/form-data">
<input type="file" name="file_data" size="20">&nbsp;
<br>
<input type="text" name="short_title" size="20"> Short Description
<br>
<input type="Submit" name="Submit" value="Upload">
<input type="HIDDEN" name="$session_name" value="$session_id">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
</H3>
</form>

<p class="vp">
<form name="Photo Gallery "method="POST" action="photoview.php">
<input type="Submit" value="View">
<input type="HIDDEN" name="$session_name" value="$session_id">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
</p>
</form>

<H3 class="pic">
<?php
include 'db.php';

// get the variables from home page
$password = $_SESSION;
$email_address = $_SESSION;

$sql_update = mysql_query("UPDATE myd SET file_data='file_date',
short_title='$short_title', mime_type='$mime_type' WHERE
email_address='$email_address' AND password='$password'");

$fileHandle = fopen($file_data, "r");
$fileContent = stripslashes($file_data);

// P.S I have used: fread() fscanf() and others all I get is errors!

$sql_check_num = mysql_num_rows($sql_check);
if($sql_check_num == 0){


echo ("Your pictures are not updated… try again");
} else {
echo ("Your pictures have been updated!");
}
?>
</H3>

<p class="picview">
<?echo '<img src="$file_data">';?>
</p>

THIS IS WHAT THE ERROR SHOWS – NOW THE PICTURE IS NOT ON MY SERVERS DIRECTORY BUT THE PICTURE IS IN THE MYSQL DATABASE…

CAN I RETRIEVE THE PICTURES FROM MYSQL DATABASE WITHOUT THEM BEING IN THE DIRECTORY? AND HOW – HOW DO I GET THE PHP TO DETEMINE THE FILE TYPE GIF, JPEG ETC… - HOW DO I STRIP THE C:\\ BLAH BLAH BLAH…

Again Your Help Is Much Appreciated, Thank-You Puddin

This Is What The Page Is Displaying No Picture Comes Up!

Photo Title: rock
File Type:
Photo Name: C:\\Documents and Settings\\LC\\My Documents\\My Pictures\\roadblock.gif

Pictures\\roadblock.gif): failed to open stream: No such file or directory in /storage/hostingfs/32/25432/puddinpatchdatematch.com/public/photos.php on line 229

Your pictures have been updated!

Recommended Answers

All 2 Replies

There are a number of errors in your logic here. The first is that you are not storing the image in the database, just the local path name to it. I would suggest that you store your images in a directory, and a path to the image in the database.

You will actually need to upload the image to the server. Have a read up on the PHP functions move_uploaded_file, ImageCreateFromJpeg, and ImageCreateFromGif, which should give you most of the info you need to get started.

hi i actually need this also. does anyone of you knows a good tutorial for a php gallery?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.