Tengo un sistema de notas (tambien se podria llamar sist. de noticias) el cual es simple, contiene 1 titulo, una clase de periodista, texto corto, texto largo, fecha de publicacion y ademas, puse la opcion de subir fotos. Max de fotos 3, pero se puede poner 0,1,2 o 3 fotos. El tema es q no me toma lo de las fotos, toma como q no estoy queriendo subir ninguna y si, intento subir 1 sola....
Les dejo el codigo:
Código PHP:
include("../config.php");
if(isset($_POST['boton'])){
$periodista = $_POST['periodista'];
$titulo = $_POST['titulo'];
$texto_breve = $_POST['texto_breve'];
$texto = $_POST['texto'];
$imagen1 = $_POST['archivo1'];
$imagen2 = $_POST['archivo2'];
$imagen3 = $_POST['archivo3'];
if($imagen1!=NULL){
$completo1 = $_FILES['archivo1']['name'];
// IMAGENES
if (is_uploaded_file($HTTP_POST_FILES['archivo1']['tmp_name'])) {
if (move_uploaded_file($_FILES['archivo1']['tmp_name'], $_FILES['archivo1']['name'])) {
$subio1 = true;
}else{ echo '<h1 align="center">Problema para mover el archivo1</h1>'; }
}else{ echo '<h1 align="center">Problema con archivo1 temporal</h1>'; }
// IMAGENES
}else{
$completo1 = 'nada';
$subio1 = true;
}
if($imagen2!=NULL){
$completo2 = $_FILES['archivo2']['name'];
// IMAGENES
if (is_uploaded_file($HTTP_POST_FILES['archivo2']['tmp_name'])) {
if (move_uploaded_file($_FILES['archivo2']['tmp_name'], $_FILES['archivo2']['name'])) {
$subio2 = true;
}else{ echo '<h1 align="center">Problema para mover el archivo1</h1>'; }
}else{ echo '<h1 align="center">Problema con archivo1 temporal</h1>'; }
// IMAGENES
}else{
$completo2 = 'nada';
$subio2 = true;
}
if($imagen3!=NULL){
$completo3 = $_FILES['archivo3']['name'];
// IMAGENES
if (is_uploaded_file($HTTP_POST_FILES['archivo3']['tmp_name'])) {
if (move_uploaded_file($_FILES['archivo3']['tmp_name'], $_FILES['archivo3']['name'])) {
$subio3 = true;
}else{ echo '<h1 align="center">Problema para mover el archivo1</h1>'; }
}else{ echo '<h1 align="center">Problema con archivo1 temporal</h1>'; }
// IMAGENES
}else{
$completo3 = 'nada';
$subio3 = true;
}
$dia = date ("d");
$mes = date ("m");
$ano = date ("Y");
$fecha = $dia.'/'.$mes.'/'.$ano;
if($subio1 || $subio2 || $subio3) {
$query = "INSERT INTO notas (periodista, titulo, texto_breve, texto, fecha, imagen1, imagen2, imagen3) VALUES('$periodista', '$titulo', '$texto_breve', '$texto', '$fecha', '$completo1', '$completo2', '$completo3')";
mysql_query($query) or die(mysql_error());
echo '<h1 align="center">La nota se ha enviado con EXITO</h1><br><br>';
}
}
?>
<form action="ingresar.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="370" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td><strong>Periodista:</strong></td>
</tr>
<tr>
<td><input name="periodista" type="radio" value="1">
Noelia
<input name="periodista" type="radio" value="2">
Gabriel
<input name="periodista" type="radio" value="3">
Graciela
<input name="periodista" type="radio" value="4">
Estefania</td>
</tr>
<tr>
<td> </td>
</tr>
<tr></tr>
<tr>
<td><h2>Titulo</h2></td>
</tr>
<tr>
<td><input name="titulo" type="text" class="file" id="titulo" size="60" /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><h2>Texto breve</h2></td>
</tr>
<tr>
<td><div align="center">
<textarea name="texto_breve" cols="60" rows="10" class="file" id="texto_breve" onfocus="elEditor = ini_editor(this)" onchange="prever()"></textarea>
</div></td>
</tr>
<tr></tr>
<tr>
<td> </td>
</tr>
<tr>
<td><h2>Texto extendido</h2></td>
</tr>
<tr></tr>
<tr>
<td><table width="100" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="12,5%"><img src="negrita.jpg" alt="Negrita" width="30" height="30" onclick="formatear(this, 'Negrita')"></td>
<td width="12,5%"><img src="cursiva.jpg" alt="Cursiva" width="30" height="30" onclick="formatear(this, 'Cursiva')"></td>
<td width="12,5%"><img src="subrayado.jpg" alt="Subrayado" width="30" height="30" onclick="formatear(this, 'Subrayado')"></td>
<td width="12,5%"><img src="izquierda.jpg" alt="Izquierda" width="30" height="30" onclick="formatear(this, 'Izquierda')"></td>
<td width="12,5%"><img src="centro.jpg" alt="Centro" width="30" height="30" onclick="formatear(this, 'Centro')"></td>
<td width="12,5%"><img src="derecha.jpg" alt="Derecha" width="30" height="30" onclick="formatear(this, 'Derecha')"></td>
<td width="12,5%"><img src="enlace.jpg" alt="Enlace" width="30" height="30" onclick="direccion(this, 'Enlace')"></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center"><textarea name="texto" cols="60" rows="10" class="file" id="texto" onfocus="elEditor = ini_editor(this)" onchange="prever()"></textarea></td>
</tr>
<tr>
<td align="center"> </td>
</tr>
<tr>
<td align="center"><strong>Fotos:</strong></td>
</tr>
<tr>
<td align="center"><input name="archivo1" type="file" id="archivo1" class="file" /></td>
</tr>
<tr>
<td align="center"><input name="archivo2" type="file" id="archivo2" class="file" /></td>
</tr>
<tr>
<td align="center"><input name="archivo3" type="file" id="archivo3" class="file" /></td>
</tr>
</table>
<br><br>
<div align="center"><input name="boton" id="boton" class="boton" type="submit" value="Enviar" onclick="ap_showWaitMessage('waitDiv', 0);">
</div>
</form>