moo - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of moo.php
- <?php
- <?php
- $marke = $_POST['marke'];
- $modell = $_POST['modell'];
- $preis = $_POST['preis'];
- $bild = $_FILES['bild'];
- $bildName = $bild['name'];
- $bildTmpName = $bild['tmp_name'];
- $bildSize = $bild['size'];
- $bildError = $bild['error'];
- $bildExt = strtolower(pathinfo($bildName, PATHINFO_EXTENSION));
- $erlaubteFormate = array('jpg', 'jpeg', 'png');
- if (in_array($bildExt, $erlaubteFormate)) {
- if ($bildError === 0) {
- if ($bildSize < 5000000) {
- $zielOrdner = 'bilder/';
- $neuerBildName = uniqid('', true) . '.' . $bildExt;
- $bildZiel = $zielOrdner . $neuerBildName;
- move_uploaded_file($bildTmpName, $bildZiel);
- // Hier kannst du den Code einfügen, um die Fahrzeugdaten und den Bildpfad in der Datenbank zu speichern
- echo "Fahrzeug erfolgreich hinzugefügt!";
- } else {
- echo "Das hochgeladene Bild ist zu groß!";
- }
- } else {
- echo "Beim Hochladen des Bildes ist ein Fehler aufgetreten!";
- }
- } else {
- echo "Nur JPG, JPEG und PNG Dateien sind erlaubt!";
- }
- ?>