so what exactly is the problem?
bastien
From: "mel list_php" <list_php@xxxxxxxxxxxxx>
To: php-db@xxxxxxxxxxxxx
Subject: mysql - image storing
Date: Tue, 18 Jan 2005 11:30:12 +0000
Hi list,
I try to store/retrieve pictures into MySQL.
I know that a lot of people will say this is not a good practice, so here
are briefly my reasons:
-I want to protect that pictures (restricted access)
-I don't want to use htaccess as I want my users to be able to modify their
password whenever they want, and I don't want to modify dynamically an
htaccess file.
-I could store them on the filesystem (my actual solution), but I have only
few pictures, so I would like to give the MySQL option a trial.
I found on the web a lot of tutorials on how to do that, they almost all
look like this one
http://www.phpbuilder.com/columns/florian19991014.php3?page=1
I went through a lot of forums, saw a lot of problems and still am unable
to make it work for me.
Here are my scripts
-for the upload into mysql I suppose all is ok as I am able to visualize
the pictures through phpMyAdmin
-for the retrieval
<?require ("./connexion.php");
$result = mysql_query("select * from images_binaires where id=1;") or
die(mysql_error());
while( $row = mysql_fetch_array($result ) )
{
$donnees=stripslashes($row[donnees_binaires]);
$type=$row[type_fichier];
$taille_fichier=$row[taille_fichier];
}
if ($donnees) {
header('Content-Type: image/png');
header('Content-Length: $taille_fichier');
echo $donnees;
}
else {
echo 'error';
}
?>
and the calling script:
<?
require ("./connexion.php");
echo"<img src='./afficher_image_public.php'>";
?>
what I can say:
-no problem with connexion, it retrieves data (echo of $donnees without
header)
-when I retrieve the data without the header, they look "normal", no excess
of slashes for example.
-I tried to open the file with "rb" for upload (even if it's supposed to be
by default now)
-I tried to put the header on top of the script
-I tried different combinations with addslashes/stripslashes, trim in case
of spaces, mysql_real_escape_string...
-I also tried with imagecreatefromstring(), even if I saw that it shouldn't
be necessary.
-I think I shouldn't need the GD library, but it's installed anyway
If somebody can help?
Thanks!
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php