Foros del Web » Programando para Internet » PHP »

problemas con subir varias imagenes a base de datos

Estas en el tema de problemas con subir varias imagenes a base de datos en el foro de PHP en Foros del Web. Hola! estoy trabajando en un sistema de clientes en el cual debo subir varias imagenes a un mismo cliente, sin embargo no logro agregarlas a ...
  #1 (permalink)  
Antiguo 14/02/2013, 16:35
 
Fecha de Ingreso: enero-2013
Mensajes: 4
Antigüedad: 11 años, 3 meses
Puntos: 0
problemas con subir varias imagenes a base de datos

Hola!

estoy trabajando en un sistema de clientes en el cual debo subir varias imagenes a un mismo cliente, sin embargo no logro agregarlas a la base de datos, por alguna razon si logro guardarlas en la carpeta pero solo inserto una.

la subida es de una en una.-

aqui esta mi codigo

imagen.new.php


<?php
include "functions.php";
include "data/dataBase.php";
global $DATA;
$ide=$_REQUEST['ide'];

?>
<!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>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script>
function validar(){
if(document.getElementById('imagen1').value==""){
document.getElementById('error').innerHTML="Selecc ione una imagen!";
document.getElementById('error').style.display="bl ock";
return 0;
}
else if(document.form1.imagen1.value.substr(document.fo rm1.imagen1.value.length-3)!="jpg" && document.form1.imagen1.value.substr(document.form1 .imagen1.value.length-3)!="JPG"){
document.getElementById('error').innerHTML="Selecc ione una imagen en formato JPG!";
document.getElementById('error').style.display="bl ock";
return 0;
}
else if(document.getElementById('tipoimg').value=="none "){
document.getElementById('error').innerHTML="Selecc ione una clasificacion para la imagen!";
document.getElementById('error').style.display="bl ock";
return 0;
}
else if(document.getElementById('descripcion').value==" "){
document.getElementById('error').innerHTML="Ingres e una Descripcion para la imagen!";
document.getElementById('error').style.display="bl ock";
return 0;
}
else{
document.form1.submit();
}
}
</script>
</head>
<body>
<table width="850" align="center">
<tr>
<td colspan="2" align="center"><form action="expediente.imagen.new.do.php" target="imagenNueva" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="90%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><table width="50%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td style="padding-left:10px;" class="formu"><strong>Seleccione la im&aacute;gen que desea guardar:</strong><br>
<input type="file" name="imagen1" id="imagen1" class="form" />
<input name="ide" type="hidden" id="ide" value="<?=$ide;?>" /></td>
</tr>
<tr>
<td style="padding-left:10px;" valign="top" class="formu"><strong>Tipo de imagen:</strong> <br>
<select name="tipoimg" id="tipoimg" class="form">
<option value="none">Seleccione...</option>
<?
$ti="select * from tiposimagenes";
$rt=$DATA->Execute($ti);
while(!$rt->EOF)
{
?>
<option value="<?=$rt->fields['IdTipoImagen']?>"><?=$rt->fields['TipoImagen']?></option>
<?
$rt->MoveNext();
}
$rt->Close();
?>
</select>
</td>
</tr>
<tr>
<td style="padding-left:10px;" valign="top" class="formu"><strong>Descripci&oacute;n:</strong> <br /><textarea name="descripcion" id="descripcion" cols="35" rows="3"></textarea> </td>
</tr>
<tr>
<td style="padding-left:10px;" class="form"><input type="button" name="save" id="save" value="Guardar Imagen" onclick="validar();"/>
<input type="button" name="return" id="retunr" value="Regresar a Galeria" onclick="javascript:window.location='expediente.im agenes.php?id=<?=$ide?>';"/>
</td>
</tr>
<tr>
<td>
<div id="error" class="msg-error" style="display:none;"></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

<iframe frameborder="0" src="about:blank" width="0" height="0" name="imagenNueva" id="imagenNueva"></iframe>
</body>
</html>


imagen.new.do.php



<?
$path="/img_expedientes";
if($_FILES['imagen1']['tmp_name']!=""){
$fecha=date('Y-m-d');
$ide=$_POST["ide"];
$ti=$_POST['tipoimg'];
$desc=$_POST['descripcion'];
include("classes/simpleimage.class.php");
$newfile=mktime().".jpg";
$var_name_img = $newfile;
$var_img_dir = "img_expedientes/images/";
$imagen= $var_img_dir.$var_name_img;
//subida de imagen normal
move_uploaded_file($_FILES["imagen1"]["tmp_name"], $imagen);
//crear thumb
$obj_simpleimage = new SimpleImage();
$obj_simpleimage->load($imagen);
$obj_simpleimage->resize(100,75);
$var_name_img = $newfile;
$var_img_dir = "img_expedientes/thumbs/";
$imagen2= $var_img_dir.$var_name_img;
$obj_simpleimage->save($imagen2);
include("data/dataBase.php");
global $DATA;
$sql="INSERT INTO imagenes_expedientes(IdExpediente,IdTipoImagen, Fecha, Descripcion, Thumb, Imagen) VALUES(?,?,?,?,?,?)";
$rs=$DATA->Execute($sql,array($ide,$ti,$fecha,$desc,$newfile ,$newfile));
}
?>
<script>
alert('Imagen guardada con exito');
window.parent.document.getElementById('form1').res et();
window.parent.document.getElementById('ide').value ='<?=$ide?>';
window.parent.document.getElementById('error').sty le.display="none";
</script>


gracias por su ayuda.

Etiquetas: mysql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:09.