-3
I’m following a tutorial on Youtube
I intend to use this upload system later in conjunction with the basic system I am creating for personal use.
I did exactly what the tutorial says except for being using the PDO connection template* .
By choosing the file and clicking send simply I go back to my page without any error, without any file and without anything in the database.
Follow my code for analysis:
<?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 Pastebin because here it was going wrong, outside the block I’m not yet expert around here
Does anyone know what happens?
Thanks so much for all your help
It might be some configuration in your php conf. Try to force errors to show in the return php. gives a look at this link http://forum.imasters.com.br/topic/369899-resolvidoforcar-o-php-a-showos-bugs/ am not php expert, but always solves my problems seeing the errors returned by php.
– Ewerson