I am trying to build a little upload script which uploads data as a blob to my database. I made a really simple form like that:
<form action="admin.php" method="post">
<input type="file" name="datei">
<br>
<input type="submit" value="Upload!">
</form>
And my PHP File as that:
if (isset($_FILES["datei"]) && isset($_FILES["datei"]["tmp_name"]) && is_uploaded_file($_FILES["datei"]["tmp_name"])) {
try {
$con = new MySQLi("localhost", "tom", "DBdb123#", "db");
if ($con) {
$name = basename($_FILES["datei"]["tmp_name"]);
$datei = $_FILES["datei"];
$sql = "INSERT INTO dateien (name, datei) VALUES (?, ?)";
$kommando = $db->prepare($sql);
$kommando->bind_param("sb", $name, $datei);
try {
$kommando->execute();
echo "Upload erfolgreich!";
} catch(Exception $ex) {
echo "Fehler: " . $ex->getMessage() . "!";
}
$db->close();
}
} catch (Exception $ex) {
echo "Fehler: " . $ex->getMessage();
}
}
So I request a error message after both try
's but after a test, nothing happened. No error, no successfull message, no database entry.. just as I didn't click/upload anything. I am trying this for an hour now and nothing changes.. that's really frustrating.