Kod
<?php
class zdjecie
{
public $foto;
public function __construct()
{
$this->baza = $GLOBALS['bd'];
}
//wysylanie zdjecia do bazy mysql
public function dodaj($idprodukt)
{
$dane = $this->foto['tmp_name'];
$f = addslashes(file_get_contents($dane));
$typ = $this->foto['type'];
//zapytanie
$q = "insert into zdjecie (Zdjecie, Format, IDProdukt) values ('$f', '$typ', '$idprodukt')";
$wyslano = mysql_query($q);
return $wyslano;
}
//Wczytanie zdjecia
public function otworz($idzdjecie)
{
$q = "select * from zdjecie where IDZdjecie = '$idzdjecie'";
$zd = mysql_query($q);
return $zd;
}
public function sprawdz()
{
if ($this->foto['type'] == "image/jpeg" || $this->foto['type'] == "image/jpg" || $this->foto['type'] == "image/png")
{
return TRUE;
}
else
{
return FALSE;
}
}
}
?>
class zdjecie
{
public $foto;
public function __construct()
{
$this->baza = $GLOBALS['bd'];
}
//wysylanie zdjecia do bazy mysql
public function dodaj($idprodukt)
{
$dane = $this->foto['tmp_name'];
$f = addslashes(file_get_contents($dane));
$typ = $this->foto['type'];
//zapytanie
$q = "insert into zdjecie (Zdjecie, Format, IDProdukt) values ('$f', '$typ', '$idprodukt')";
$wyslano = mysql_query($q);
return $wyslano;
}
//Wczytanie zdjecia
public function otworz($idzdjecie)
{
$q = "select * from zdjecie where IDZdjecie = '$idzdjecie'";
$zd = mysql_query($q);
return $zd;
}
public function sprawdz()
{
if ($this->foto['type'] == "image/jpeg" || $this->foto['type'] == "image/jpg" || $this->foto['type'] == "image/png")
{
return TRUE;
}
else
{
return FALSE;
}
}
}
?>
$zdjecie->foto = $_FILES['zdjecie1'];
$zdjecie->dodaj($idproduktu);
W każdym razie, zdjęcie jest zapisane w bazie.. Ale poźniej jak go pobieram i ustawiam header to go nie wyświetla... Bo obrazek zawiera bledy, więc myślę że powstaly one przy zapisie do bazy.