Ver Mensaje Individual
  #5 (permalink)  
Antiguo 14/05/2010, 15:30
alfredo22r
 
Fecha de Ingreso: septiembre-2007
Mensajes: 9
Antigüedad: 16 años, 7 meses
Puntos: 0
Respuesta: Ayuda PHP y PostgreSQL campo BYTEA

Hola, te agradesco mucho la ayuda, busque la informacion y pude resolver mi problema. Aqui dejo el código por si alguien lo necesita:

<?php


if (isset($_POST['boton'])) {

if (is_uploaded_file($_FILES['archivo']['tmp_name']))
{
$local = $_FILES['archivo']['name'];
$remoto = $_FILES['archivo']['tmp_name'];
$tipo = $_FILES['archivo']['type'];
$extension = explode(".", $local);


if (!is_dir("archivos")) mkdir("archivos",0777);

$ruta = "archivos/" . $local;


if(move_uploaded_file($remoto, $ruta))
{
$conexion_bd = pg_connect("host=localhost dbname=ISO17799 user=postgres password=postgres")
or die('No pudo conectarse: ' . pg_last_error());

$pregunta=($_GET['pregunta']);

$t = '"';
$consulta = "UPDATE preguntas SET ".$t."cRutArc".$t."='$ruta' WHERE ".$t."cCodPre".$t."='$pregunta'";

$resultado = pg_query($consulta) or die('Consulta fallida: ' . pg_last_error());

?>
<style type>
#mensaje {

visibility:hidden;
}

</style>
<?php

echo "<div style='font-size:16px' align='center' ><br><br>Archivo subido correctamente</br></br></div>";

}

else

echo "Error al Mover el archivo";

}

}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Guardar Archivo</title>
</head>

<style type>
body {
margin: 0;
padding: 0;

font: normal 11px Tahoma, Arial, Helvetica, sans-serif;
color: #666666;
background-color:#F49500;
}

</style>

<body>

<?php $pregunta=($_GET['pregunta']); ?>

<form action="Guardar.php?pregunta=<?php echo $pregunta; ?>" method="POST" enctype="multipart/form-data" name="form1">
<div id="mensaje">
<p align="center">Archivo
<input name="archivo" type="file" id="archivo">
</p>
<p align="center">
<input name="boton" type="submit" id="boton" value="Guardar">
</p>
</div>
</form>




</body>
</html>