Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/01/2012, 13:38
jeffer480
 
Fecha de Ingreso: enero-2012
Ubicación: cabudare
Mensajes: 5
Antigüedad: 12 años, 3 meses
Puntos: 0
Mensaje como subir varias imagenes en php

Buenas tardes tengo un problema para editar el siguiente codigo, resulta que edite un sistema de imagenes para noticias, y funcionaba bien, ahora, el problema es que el cliente ahora quiere que en vez de una foto tena varias. si alguien me puede ayudar.

este es el codigo del formulario

<?php
$chequeoone= $_GET['Id'];
//echo $chequeoone;
If($_GET['Id'] == "") {


//echo " entra al get ID noticias";
//echo $chequeo;

}
else {

include("functions.php");
// echo "cuando entra al else del get";
$link = conectar();
conectardb();

//Ejecutamos la sentencia SQL
$query = mysql_query("SELECT * from noticias where month(fecha) = ". $_GET['Id'] ." Order By fecha desc",$link);

$total = mysql_num_rows($query);

if($total == 0) {
echo '<font style="color:red">No se encontraron noticias registradas para el mes seleccionado.</font>';
}
else {

echo '<table width="650" border="0" cellpadding="0" cellspacing="0"><tr>';
echo '<th align="left" width="180" scope="col" >Titulo</th>';
echo '<th align="left" width="180" scope="col" >Descripcin</th>';
echo '<th align="left" width="180" scope="col" >Detalle</th>';
echo '<th align="right" width="52" scope="col" >Fecha</th>';
echo '<th width="50" scope="col">&nbsp;</th>';
echo '</tr></table>';

$apuntador = 0;
while ($fila=mysql_fetch_array($query))
{
$apuntador ++;
if(pow(-1,$apuntador) == 1) {
$ColorFila = "#05a4cc"; //color de CE9DFF
}
else
{
$ColorFila = "#0abfe4"; // color de fondo del reporte ECD9FF
}
echo '<table height="25" bgcolor="' . $ColorFila . '" width="650" border="0" cellpadding="0" cellspacing="0"><tr>';
echo '<th align="left" width="180" scope="col" >&nbsp;&nbsp;' . cut_cadena($fila['titulo'], 18) . '</th>';
echo '<th align="left" width="180" scope="col" >' . cut_cadena($fila['descripcion'], 25) . '</th>';
echo '<th align="left" width="180" scope="col" >' . cut_cadena($fila['detalle'], 25) . '</th>';
echo '<th align="right" nowrap="nowrap" width="52" scope="col" >' . $fila['fecha'] . '</th>';
echo '<th align="center" width="25" scope="col"><a href="enoticia.php?Id=' . $fila['id_noticia'] . '&Idmes=' . $_GET['Id'] . '"><img src="imagenes/ipanel/Editar16x16.png" width="16" height="16" border="0" /></a></th>';
echo '<th align="center" width="25" scope="col"><a href="eliminarnoticia.php?Id=' . $fila['id_noticia'] . '&Idmes=' . $_GET['Id'] . '&file=' . $fila['foto'] . '"><img src="imagenes/ipanel/Eliminar16x16.png" width="16" height="16" border="0" /></a></th>';
echo '</tr></table>';
}
}

mysql_free_result($query);
mysql_close($link);

echo '</p>';

echo '<table width="650" border="0" cellpadding="0" cellspacing="0">
<tr>
<th scope="col">&nbsp;</th>
</tr>
</table>
<table width="650" border="0" cellpadding="0" cellspacing="0" height="20">
<tr>
<th width="36" scope="col" align="center">&nbsp;<img src="imagenes/ipanel/Nuevo.png" width="25" height="25" /></th>
<th width="612" scope="col" align="left">&nbsp;&nbsp;Agregar Noticia
</tr>
<tr height="15">
<th scope="col" align="center">&nbsp;</th>
<th scope="col" align="left" >&nbsp;</th>
</tr>
</table>
<form action="guardarnoticia.php" enctype="multipart/form-data" method="post">
<table width="650" border="0">
<tr>
<th width="134" scope="col" valign="top" align="left"> Titulo</th>
<th width="506" scope="col" valign="top" align="left"><input name="titulo" type="text" id="Titulo" size="80%"/>
</label></th>
</tr>
<tr>
<th scope="col" valign="top" align="left">Descripci&oacute;n</th>
<th scope="col" valign="top" align="left"><label>
<textarea name="descripcion" cols="60%" rows="8" id="Desripcion"></textarea>
</label></th>
</tr>
<tr>
<th scope="col" valign="top" align="left">Detalle</th>
<th scope="col" valign="top" align="left"><textarea name="detalle" cols="60%" rows="8" id="detalle"></textarea></th>
</tr>
<tr>
<th scope="col" valign="top" align="left">Dia, Mes, A&ntilde;o </th>
<th scope="col" valign="top" align="left"><select name="dia">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
</label>
<select name="mes">
<option value="1">Enero</option>
<option value="2">Febrero</option>
<option value="3">Marzo</option>
<option value="4">Abril</option>
<option value="5">Mayo</option>
<option value="6">Junio</option>
<option value="7">Julio</option>
<option value="8">Agosto</option>
<option value="9">Septiembre</option>
<option value="10">Octubre</option>
<option value="11">Noviembre</option>
<option value="12">Diciembre</option>
</select>
<select name="anho">
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009" selected="selected">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
</select></th>
</tr>
<tr>
<th scope="col" valign="top" align="left">Fotograf&iacute;a</th>

<th scope="col" valign="top" align="left">
<input name="foto" type="file" size="60%"/>
<input value="';
echo $_GET['Id'];
echo '" type="hidden" name="idmes"/></th>
</tr>
</table>
<table width="650" border="0" cellpadding="0" cellspacing="0">
<tr>
<th scope="col">&nbsp;</th>
</tr>
</table>
<table width="650" border="0" cellpadding="0" cellspacing="0">
<tr>
<th scope="col"><input type="submit" name="submit" value="Guardar" class="Boton" /></th>
</tr>
<tr>
<th scope="col">&nbsp;</th>
</tr>
</table>
</form>';
}
?>

y este es el php

<?php
include("../functions.php");

$link=conectar();
conectardb();

$titulo=$_POST['titulo'];
$descripcion=$_POST['descripcion'];
$detalle=$_POST['detalle'];
//$foto=$_FILES['foto']['name']; //nombre de la foto
$foto = $HTTP_POST_FILES['foto'];
$count = count($foto);
for($i=0;$i<$count;$i++){
echo $foto[$i]['tmp_name'];
}

//lo que se guarda en bd

//echo $foto;
$fecha = $_POST['anho'].'/'.$_POST['mes'].'/'.$_POST['dia'];
//echo $fecha;
$valor=$_FILES['foto']['tmp_name'];
//echo $valor;
$query0=mysql_query("SELECT * FROM noticias where foto = '$foto'" ,$link);

$total0=mysql_num_rows($query0);

if (($total0=="0") && ($titulo!="") && ($descripcion!="") && ($detalle!="") && ($foto!="")) {
//luego con esta instruccion muevo la imagen a una carpeta dentro de mi servidor
mysql_query("insert into noticias (titulo,descripcion,detalle,foto,fecha) values ('$titulo','$descripcion','$detalle','$foto','$fec ha')",$link);

copy($_FILES['foto']['tmp_name'],'fotos/noticias/' . $_FILES['foto']['name']);

//$fotoname=$_FILES['foto']['name'];
//echo $fotoname;
$chequeo=$_POST['idmes']; //numero del mes
//echo $chequeo;
header("Location: noticias.php?Id=" . $_POST['idmes']);
}
else{
header("Location: noticias.php?Error=1");
}?>

si alguien me ayuda le estare muy agradecido