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.



Your result can be seen below.

Result of php executing





Full code of moo.php

  1. <?php
  2. <?php
  3. $marke = $_POST['marke'];
  4. $modell = $_POST['modell'];
  5. $preis = $_POST['preis'];
  6.  
  7. $bild = $_FILES['bild'];
  8. $bildName = $bild['name'];
  9. $bildTmpName = $bild['tmp_name'];
  10. $bildSize = $bild['size'];
  11. $bildError = $bild['error'];
  12.  
  13. $bildExt = strtolower(pathinfo($bildName, PATHINFO_EXTENSION));
  14. $erlaubteFormate = array('jpg', 'jpeg', 'png');
  15.  
  16. if (in_array($bildExt, $erlaubteFormate)) {
  17.   if ($bildError === 0) {
  18.     if ($bildSize < 5000000) {
  19.       $zielOrdner = 'bilder/';
  20.       $neuerBildName = uniqid('', true) . '.' . $bildExt;
  21.       $bildZiel = $zielOrdner . $neuerBildName;
  22.       move_uploaded_file($bildTmpName, $bildZiel);
  23.  
  24.       // Hier kannst du den Code einfügen, um die Fahrzeugdaten und den Bildpfad in der Datenbank zu speichern
  25.  
  26.       echo "Fahrzeug erfolgreich hinzugefügt!";
  27.     } else {
  28.       echo "Das hochgeladene Bild ist zu groß!";
  29.     }
  30.   } else {
  31.     echo "Beim Hochladen des Bildes ist ein Fehler aufgetreten!";
  32.   }
  33. } else {
  34.   echo "Nur JPG, JPEG und PNG Dateien sind erlaubt!";
  35. }
  36. ?>
  37.  
File Description
  • moo
  • PHP Code
  • 22 May-2023
  • 1019 Bytes
You can Share it: