I am getting the error that my index is undefined in $_FILES. I am trying to copy a picture with php on my server.
Error:
PHP Notice: Undefined index: bilddatei in C:\inetpub\wwwroot\aufgabe8.php on line 85
PHP Notice: Undefined variable: namefile in C:\inetpub\wwwroot\aufgabe8.php on line 86
I've already tried with isset($_FILES["bilddatei"]) but this returns false too.
Code:
<?php
session_start();
if (!isset($_SESSION['Datenbank']) and
!isset($_SESSION['Kennung']) and !isset($_SESSION['Passwort']) )
{
echo "<p>Bitte starten Sie zuerst mit der Eingabe-Startseite. Sie werden automatisch nach 5 Sekunden weitergeleitet.</p>";
// automatisches Zurueckspringen nach 5 Sekunden nach 'index.html':
echo '<meta http-equiv="Refresh" content="5;url=login.php">';
} else {
echo "<form action=\"aufgabe8.php\" method=\"post\" enctype=\"multipart/form-data\">
<p>Datei von PC hochladen
<input type=\"file\" name=\"bilddatei\" size\"60\" accept=\"image/*\"/>
</p>
<p><input type=\"submit\" value=\"Bild anzeigen\" name=\"bildBtn\"/></p>
</form>";
if(isset($_POST["bildBtn"])) {
echo "<p>BILD IF</p>";
$nameFile = $_FILES['bilddatei']['name'];
echo "<p>$namefile</p>";
//copy($fileSource,$destination);
}
Do you have any ideas? Thanks! :-)