File upload via PHP does not work, no error returned (localhost, XAMPP, ubuntu)

-3

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?

Screenshot

Thanks in advance for all your help

    
asked by anonymous 07.05.2016 / 00:21

2 answers

0

It should be because of this line here:

<input type=\"file\" required nome="arquivo"  />

You have to swap for:

<input type="file" required name="arquivo"  />

And if it is already known that you may have problems with the term "required" in some browsers that treat this word differently.

I did not test, try that!

I hope it helps

    
07.05.2016 / 12:41
0

The input is wrong. It is not name="file" and yes name="file"

<input type="file" required name="arquivo"  />
    
07.05.2016 / 16:32