Updated: Someone who can help me with this code friends, I have to save an image in server and database. The problem is that it saves the image on the server, but the insert query that I have is not executed.
//*--------------------------------Se guarda la imagen----------------------------*
$file = $_FILES["file"];
$nombre = getUniqueName()."";
$tipo = $file["type"];
$ruta_provisional = $file["tmp_name"];
$size = $file["size"];
$carpeta = "upload/";
switch ($tipo) {
case 'image/jpg':
$tipo = JPG;
break;
case 'image/jpeg':
$tipo = JPEG;
break;
case 'image/png':
$tipo = PNG;
break;
case 'image/gif':
$tipo = GIF;
break;
default:
die("Error, el archivo no es una imagen");
}
$src = $carpeta.$nombre;
move_uploaded_file($ruta_provisional, $src);
changeSize($src, 500, $tipo);
echo "<img src='$src'>";
//Aqui necesito ingresar $src a la bd, pero no se ejecuta(La sentencia esta probada y funciona correctamente)
$con = Conectar();
$sql = 'INSERT INTO bolsa (id, tipo_bolsa, titulo, imagen, descripcion, categoria, fecha, sueldo) VALUES (:id, :tipo_bolsa, :titulo, :imagen, :descripcion, :categoria, :fecha, :sueldo)';
$q = $con->prepare($sql);
$q->execute(array(':id'=>$id, ':tipo_bolsa'=>$tipo_bolsa, ':titulo'=>$titulo, ':imagen'=>$src, ':descripcion'=>$descripcion, ':categoria'=>$categoria, ':fecha'=>$fecha, ':sueldo'=>$sueldo));