Claas M
Erfahrenes Mitglied
Hallo.
Ich trage meine Bilder trotz Nachteile als Binärdaten in eine Tabelle mit anderem Schnickschnack ein, was auch prima klappt.
Das Auslesen soweit auch aber anstatt das Bild anzuzeigen, wird es als Binärtext ausgegeben.
Wisst ihr, wie ich das 'On the Fly' umschalten kann? Alle Versionen mit header() klappen nicht.
Eintragen:
Auslesen:
Wäre echt toll, wenn mir einer von euch helfen könnte.
Ich trage meine Bilder trotz Nachteile als Binärdaten in eine Tabelle mit anderem Schnickschnack ein, was auch prima klappt.
Das Auslesen soweit auch aber anstatt das Bild anzuzeigen, wird es als Binärtext ausgegeben.
Wisst ihr, wie ich das 'On the Fly' umschalten kann? Alle Versionen mit header() klappen nicht.
Eintragen:
PHP:
<html>
<head><title>Store binary data into SQL Database</title></head>
<body>
<?php
include ("mysql.php");
include ("settings.php");
if ($submit) {
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
$result=MYSQL_QUERY("INSERT INTO ".$bildertable_prefix.$bildertable_name." (description,bin_data,filename,filesize,filetype) ".
"VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')");
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
MYSQL_CLOSE();
} else {
?>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
File Description:<br>
<input type="text" name="form_description" size="40">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<br>File to upload/store in database:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?php
}
?>
</body>
</html>
Auslesen:
PHP:
<?php
include("mysql.php");
include("settings.php");
$query = mysql_query("select * from ".$bildertable_prefix.$bildertable_name."");
while ($bild = mysql_fetch_array($query))
{
echo $bild['0'];
echo $bild['1'];
echo $bild['2'];
echo $bild['3'];
echo $bild['4'];
echo $bild['5'];
}
?>
Wäre echt toll, wenn mir einer von euch helfen könnte.