At the moment i create a little picture upload system. But i want that every picture looks same. As example i upload a picture (500x500) then i have to minimize the picture with css. I have one class
.picture{
width: 30%;
height: 30%;
}
But every picture vary in the size then. A want a fixed height and width but not like this:
.picture{
width: 200px;
height: 200px;
}
I want to do it like this page: Link On this page every picture got an other size but at the fronpage every picture look same. How can i realize something like that?
Here my Code:
*{
margin: 0px;
padding: 0px;
}
.button-submit{
margin-top: 10px;
padding: 10px 15px;
border: 2px solid black;
background-color: orange;
color: black;
transition: all 0.5s;
}
.button-submit:hover{
color: orange;
border: 2px solid orange;
background-color: black;
}
.picture{
width: 30%;
height: 30%;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="meine.css" >
</head>
<body>
<?php include "connection.php" ?>
<h1>Lade dein Bild hoch</h1>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="fileToUpload" id="fileToUpload">
<br>
<input type="submit" value="Upload Image" class="button-submit" name="submit">
</form>
<?php
$sql = "SELECT * FROM bilder";
$result=mysqli_query($db,$sql);
while($row=mysqli_fetch_assoc($result)){
echo "<img src='$row[bild_pfad]' alt='$row[bild_name]' style='$row[bild_werte]'>";
}
?>
</body>
</html>
Here the upload.php
<?php
include "connection.php";
//Ordner in dem die Datein geladen werden
$target_dir = "uploads/";
//Der Pfad (Order + / + Dateiname)
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
//Variable ob der Upload fortfahren soll
$successful = TRUE;
//Von Pfad der Anbau (MyFile.Anbau(.jpg,.png,...)) wird in eine Variable geschrieben
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
$meldung = "";
//Wurde der Submit Button gedrückt?
if(isset($_POST["submit"])){
//In dem Array werden verschiedene Werte gespeichert (Breite, Höhe, Typ), bei einem Fehler (falls kein Bild) ist der Rückgabewert False
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if(!($check == false)){
//Prüfe ob der Name bereits exestiert
if(file_exists($target_file)){
$meldung = "Der Bildname exestiert bereits.";
$successful = FALSE;
}
//Prüfe die Größe des Bildes
if($_FILES["fileToUpload"]["size"] > 500000){
$meldung = $meldung . "<br>Das Bild ist zu groß.";
$successful = FALSE;
}
//Prüfe Format des Bildes
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG") {
$meldung = $meldung . "<br>Ungültiges Format.";
$successful = FALSE;
}
}else{
echo "Die Datei ist kein Bild.";
$successful = FALSE;
}
}
//Prüfe ob ein Fehler aufgetreten ist
if ($successful == FALSE){
$meldung = $meldung . "<br>Die Datei wurde nicht hochgeladen.";
//Bei keinem Fehler
}else{
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
$picturename = $_FILES["fileToUpload"]["name"];
$pictureheightwidth = $check[3];
$picturepath = $target_file;
$eintrag = "INSERT INTO bilder (bild_name, bild_werte, bild_pfad) VALUES ('$picturename', '$pictureheightwidth', '$picturepath')";
$eintragen = mysqli_query($db, $eintrag);
$meldung = "Das Bild wurde erfolgreich hochgeladen";
} else {
$meldung = $meldung . "<br>Fehler beim hochladen des Bildes.";
}
}
echo $meldung;
?>
<a href="index.php">Zurück</a>
This Link solved my problem.