skip to Main Content

HTML:

    <form  action="submit.php" method="POST" >
 <div class="file-input">
              
              <input type="file" class="attestat" id="attestat" name="attestat" accept="application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, image/*" multiple="multiple">
              <span class="file-name">Выберите файл</span>
            </div>
</form>

and PHP:

<?php
$servername = "localhost";
$username = "root";
$password = "Youshit21";
$dbname = "medacc";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}



  $filetmpname = $_FILES["attestat"]["tmp_name"];

  $id = uniqid('user_');

  $sql = "INSERT INTO medacc.spaco(id,filo) VALUES ('$id', '$filetmpname')";
  if ($conn->query($sql) === TRUE) {
    echo "File uploaded successfully.";
  } else {
    echo "Error: " . $sql . "<br>" . $conn->error;
  }





$conn->close();

?>

and its always showing this error:
Warning: Undefined array key "attestat" in D:localhostacceptance formsubmit.php on line 14

Warning: Trying to access array offset on value of type null in D:localhostacceptance formsubmit.php on line 14

the code inserts file to mysql table , but its simply does not see the file input
and doesnt change no matter what i doyour text


Please signup or login to give your own answer.
Back To Top
Search