I'm following a Youtube tutorial
I plan to use this upload system later in conjunction with the basic system I'm creating for personal use.
I did exactly what I said in the tutorial except I was using the PDO * connection template.
By choosing the file and clicking send simply I go back to my page with no error, no files and nothing in the database.
Here is my code for review:
<?php
include('database.php');
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$msg = false;
if(isset($_FILES['arquivo'])){
$extensao = strtolower(substr($_FILES['arquivo']['name'], -4));
$novo_nome = md5(time()).$extensao;
$diretorio = "upload/";
move_uploaded_file($_FILES['arquivo']['tmp_name'], $diretorio.$novo_nome);
$sql = "INSERT INTO arquivo (codigo, arquivo, data) VALUES (null, '$novo_nome', NOW() )";
if (mysqli_query($conn, $sql))
$msg = "Arquivo upado com sucesso.";
else
$msg = "Erro ao upar arquivo" . mysqli_error($conn);}
?>
<h1> Upload de Arquivos </h1>
<?php if($msg != false) echo "<p> $msg </p>"; ?>
<form action="upload.php" method="POST" enctype="multipart/form-data">
<input type="file" required nome="arquivo" />
<input type="submit" value="Enviar" />
</form>
I put it in the pastebin because here I was going wrong, out of the block I'm not an expert around here
Does anyone know what's going on?
Thanks in advance for all your help