I have a form (in php, I wanted to ask if it works without problem?) to insert images (the path of them) and when I enter the inserted in the database but the image does not move to the folder I'm requesting.
Here is the code I downloaded:
<?php
include '../conn.php';
mysqli_set_charset($con,"utf8");
$id = $_GET['id'];
$imagem = $_FILES['imagem']['tmp_name'];
$img_name = $_FILES['imagem']['name'];
$dir = "../imagens/viaturas/";
$path = $dir.$img_name;
move_uploaded_file( $imagem, $path );
$sql = "INSERT INTO carros_img(id_fk, img) VALUES ($id, '$img_name')";
if(mysqli_query($con, $sql)){
echo "<script>
document.location.href = '../admin/carros.php?id=$id';
</script>";
}
else{
echo "<script>
alert('Imagem não enviada');
document.location.href = '../admin/quem.php?id=$id';
</script>";
}
?>
The path of the image appears in bd but the image does not move from folder. Any problems with the code?