HAllo,
ich lerne gerade PHP aber irgendwie stehe ich auf dem Schlauch.
Jemand ich möchte über ein Formular ein Bild in eine Datenbank uploaden können- das funzt auch. Aber was wenn ich nun kein Bild auswähle, soll keine Fehlermeldung erscheinen - das ist das Problem:
hat vielleicht jemand einen hilfreichen Vorschlag?
Hier mein Code:
if ($photo == ''){
print "Kein Bild";
}
if ($photo != ''){
print "$photo<br>$photo_name<br>$photo_size<br>$photo_type";
// convert to canonic name
$t=explode(".",$photo_name);
$max=count($t)-1;
$ext=$t[$max];
$photo_name=str_replace(".$ext","",$photo_name);
$filename=eregi_replace("([^a-z0-9]*)","",$photo_name);
$filename=strtolower($filename);
srand((double)microtime()*1000000);
$filename=rand(10000,99999)."_".$filename.".$ext";
// copy file
if (function_exists("move_uploaded_file")){
move_uploaded_file($photo, $photopath.$filename);
}else{
copy($photo, $photopath.$filename);
unlink($photo);
}
$info=getimagesize($photopath.$filename);
$result = dbquery($conid, "UPDATE $dbtable SET image='$filename',caption='$caption' WHERE (id='$id')");
};
};