I have a problem with uploading the image to BD MySQL! The process is carried correctly until the image of the user's computer is uploaded to my server, but after that, the statement that is responsible for saving values in the database is not executed. If I check the folder where the uploaded images are saved, there is the image, but never a record is inserted in the BD ...
This is the HTML code
<?php require 'headerAdministratorVistas.php'; ?>
<div class="contenedor">
<div class="slideshow">
<article>
<br/><br/>
<div class="posttitle">
<img src="../images/titleinfoConta.png">
</div>
<hr>
</article>
<article>
<br/>
<form class="formularioEditar" method="post" enctype="multipart/form-data" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<input type="text" name="concepto" class="contentinfo" placeholder="Forma de Contacto"><br/><br/>
<input type="text" name="informacion" class="contentinfo" placeholder="Descripción"><br/><br/>
<input type="file" name="imagen">
<input type="submit" value="Crear nueva Categoría" class="guardarcambios">
</form>
</article>
</div>
</div>
<?php require 'footer.php'; ?>
Y este, el código PHP
<?php session_start();
require 'config.php';
require '../functions.php';
comprobarSesion();
$conexion = conexion($bd_config);
if (!$conexion) {
header('Location: ../error.php');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$concepto = $_POST['concepto'];
$informacion = $_POST['informacion'];
$imagen = $_FILES['imagen']['tmp_name'];
$archivo_asubir = '../' . $pagina_config['carpeta_imagenes'] . $_FILES['imagen']['name'];
move_uploaded_file($imagen, $archivo_asubir);
$statement = $conexion->prepare(
'INSERT INTO contacto (id, concepto, informacion, image)
VALUES (null, :concepto, :informacion, :imagen)'
);
$statement->execute(array(
':concepto' => $concepto,
':informacion' => $informacion,
':imagen' => $_FILES['imagen']['name']
));
header('Location: '. RUTA . 'admin/mostrarContacto.php');
}
require '../views/nuevoContacto.view.php'; ?>