** Solved **
I have a bit of a problem with my code
i have to store images into a mysql database using php and a HTML form. I have followed a guide, but i doesnt really work. It uploads the file to the server... and then it gets abandoned... at least not stored.
for the code... the language of text and variables is... Dutch if you have problems with that part ill be glad to help out.
The database layout of the target table is:
Fotos
fotonr int(10) Index number
album varchar(20) Grouping catagory(not needed)
Lid int(4) Index number of the member that placed it
type varchar(20) To store what kind of image it is
image blob The image itself
for that i use the following segment(database links are not in the file, already build before)
<p>
<?php
$target_path= "images/";
echo "checking file upload!<br />";
if(isset($_FILES['file']))
{
echo"SET!!!<br />";
if(isset($_POST['album']))
{
$album=trim($_POST['album']);
if($album!="")
{
$album= stripslashes($album);
}
else $album="Niet Ingedeeld/";
}
else $album="Niet Ingedeeld/";
$myalbum=mysql_real_escape_string($album);
$target_path=$target_path.$album;
foreach($_FILES['file']['tmp_name'] as $key=>$afbeelding)
{
echo $_FILES['file']['name'][$key]."<br />";
if ($_FILES['file']['tmp_name'][$key]!=''){
$size = getimagesize($_FILES['file']['tmp_name'][$key]);
$width=$size[0];
$height=$size[1];
echo "groote: ".$width."x".$height."<br />";
if($width>800&&$height>600)
{
echo "Uw afbeelding is te groot!(maximaal 800x600)<br />";
}
else
{
$mynr= mysql_real_escape_string($_SESSION['nummer']);
/*$type=exif_imagetype($_FILES['file']['tmp_name'][$key]);*/
$type=$size[mime];
echo 'Het type was:'.$type.'<br /> ';
if($type=="image/gif" ||$type=="image/jpeg" ||$type=="image/bmp" ||$type=="image/png" ||$type=="image/gif" ){
$mytype =mysql_real_escape_string($type);
$tmpName = $_FILES['file']['tmp_name'][$key];
/*$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$mycontent = mysql_real_escape_string($content);*/
$content = file_get_contents($tmpName);
$data = unpack("H*hex", $content );
$mycontent = '0x'.$data['hex'];
$sql="INSERT INTO`nacverk`.`Foto` (`album` , `lid` ,`image`,`type` )VALUES ('$myalbum' ,'$mynr','$mycontent', '$mytype')";
$result=mysql_query($sql);
/*fclose($fp);*/
if(!$result)
{
echo "<h1>Bestand uploaden mislukt!<br /> ".mysql_error()."<br /></h1>";
}
else
{
echo "<h1>Bestand Succesvol geupload!<br /></h1>";
}
}
else{
echo "<h1> NOD32 detected a viral intrusion!<br /></h1>";
}
}
}}
}
mysql_query("OPTIMIZETABLE `Foto` ");
?>
</p><hr />
<h3> Upload hier uw Foto's!</h3>
<hr />
<p>
<form enctype="multipart/form-data" action="" method="post" name="foto-upload">
<input name="MAX_FILE_SIZE" value="10485760" type="hidden">
Uw afbeeldingen:<br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
<input name="file[]" type="file"><br />
Het album waar ze aan toegevoegd moeten worden:<br />
<input name="album" type="text" maxlength="20"
<?php if(isset($_GET['album']))echo ' value="'.$_GET['album'].'" '; ?>><br />
<input value="Submit" type="submit">
</form>
</p>
<hr />
It falls through till the part where it needs to get uploaded to the Database...
Then it triggers the SQL error saying: Query is empty.
Thank you for you time!