Hello everyone!
I have made 2 php files, the first displaying an html table, with the photo’s information retrieved from mysql( also having a link for displaying the image) and the other file takes the image’s id and displays it. I mean i would like it to be displayed but i have problem. It says “the image <image/path> cannot be displayed because it contains errors”.
I have stored my images in mysql as mediumblobs, also tryed all mine types and different browsers but no luck…
It’s been 3 days trying to solve this problem. Do you have any idea?
Below is my code:
imageDisplay.php
<?php
include "functions.php";
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
</head>
<body>
<table border = "1px solid black;">
<tr>
<td>id</td>
<td>user</td>
<td>type</td>
<td>name</td>
<td>comment</td>
</tr>
<?php
$result = mysql_query( "SELECT * FROM uploaded_images" );
while ( $row = mysql_fetch_assoc( $result ) )
{
echo "<tr>";
echo "<td>" . $row[ 'id' ] . "</td>";
$id = $row[ 'id' ];
echo "<td>" . $row[ 'user' ] . "</td>";
echo "<td>" . $row[ 'type' ] . "</td>";
echo "<td>" . $row[ 'name' ] . "</td>";
echo "<td>" . $row[ 'text' ] . "</td>";
echo " <td> <a href='foto.php?id=$id'>download</a> </td>\
";
echo "</tr>";
}
echo "</table>";
?>
foto.php
<?php
include( 'functions.php' );
$query = mysql_query( "SELECT * FROM uploaded_images WHERE id = 1" );
$image = mysql_fetch_assoc( $query );
$final = stripslashes( $image[ 'image' ] ) ;
$name = stripslashes( $image[ 'name' ] );
$type = stripslashes( $image[ 'type' ] );
$id = $image[ 'id' ];
header( 'Content-type:image/png' );
//header( "Content-lenght:$size" );
//header('Content-Disposition: attachment; filename=' . $name);
// header('Content-Description: PHP Generated Data');
//header( 'Content-Transfer-Encoding: binary' );
echo $final;
?>