•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,480 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,825 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1224 | Replies: 2
![]() |
•
•
Join Date: Mar 2006
Location: Montreal Quebec Canada
Posts: 52
Reputation:
Rep Power: 3
Solved Threads: 0
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">
<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['password'];
$email_address = $_SESSION['email_address'];
$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!
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">
<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['password'];
$email_address = $_SESSION['email_address'];
$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!
•
•
Join Date: Jul 2004
Location: Sydney, Australia
Posts: 166
Reputation:
Rep Power: 5
Solved Threads: 7
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.
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.
If I've been a help please confirm by clicking the Add to Lafinboy's Reputation link in the header of this reply.
Lafinboy Productions
:: Website Design :: Website Development ::
Lafinboy Productions
:: Website Design :: Website Development ::
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Help with comments box and uploading and resizing images for users (PHP)
- PHP Dynamic Images Loads Slowly! (PHP)
- PHP Variables (PHP)
- Menu Images not loading (JavaScript / DHTML / AJAX)
- Hello Dani Web members (PHP)
Other Threads in the PHP Forum
- Previous Thread: Fourm Editing
- Next Thread: Problems with PHP mail function.


Linear Mode