Ich weiß, dass dies eine lange Frage zu stellen ist, aber ist sie jemand, der mir zeigen kann, wie man ein Bild in den Ordner und den Bildnamen in die Datenbank hochlädt? Ich habe gesucht und alles, was ich finde, ist mysql. Mysql funktioniert nicht für mich Ich bekomme viele Fehler. Hier ist ein Code, den ich habe, aber es wird nicht funktionieren für michBild in Ordner und Bildname in Datenbank hochladen
<?php
$hostname_connect= "localhost";
$username_connect="torcdesi_barron7";
$password_connect= "Tazmania9292";
$database_connect="torcdesi_shirt";
// Create connection
$connect_solning = mysqli_connect($hostname_connect, $username_connect, $password_connect, $database_connect) or trigger_error(mysqli_error(),E_USER_ERROR);
mysqli_select_db($connect_solning ,$database_connect) or die (mysqli_error($connect_solning));
if($_POST)
{
// $_FILES["file"]["error"] is HTTP File Upload variables $_FILES["file"] "file" is the name of input field you have in form tag.
if ($_FILES["file"]["error"] > 0)
{
// if there is error in file uploading
echo "Return Code: " . $_FILES["file"]["error"] . "/>";
}
else
{
// check if file already exit in "images" folder.
if (file_exists("images/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{ //move_uploaded_file function will upload your image.
if(move_uploaded_file($_FILES["file"] ["tmp_name"],"images/" . $_FILES["file"]["name"]))
{
// If file has uploaded successfully, store its name in data base
$query_image = "insert into shirt_table (image) values ('".$_FILES['file']['name']."', 'display','')";
if(mysqli_query($query_image))
{
echo "Stored in: " . "images/" . $_FILES["file"]["name"];
}
else
{
echo 'File name not stored in database';
}
}
}
}
}
?>
Was ist das Problem? –