Foros del Web » Programando para Internet » PHP »

Problema al subir un archivo al servidor

Estas en el tema de Problema al subir un archivo al servidor en el foro de PHP en Foros del Web. hola buenas Estoy trabajando en una web, a la cual, le estoy creando la administracion, estoy creando un campo para cambiar las imagenes de un ...
  #1 (permalink)  
Antiguo 19/09/2012, 12:39
Avatar de ricky0123456  
Fecha de Ingreso: septiembre-2012
Ubicación: Caracas
Mensajes: 25
Antigüedad: 11 años, 7 meses
Puntos: 0
Pregunta Problema al subir un archivo al servidor

hola buenas

Estoy trabajando en una web, a la cual, le estoy creando la administracion, estoy creando un campo para cambiar las imagenes de un slider y me da este error..

Notice: Undefined index: campo en F: \ wamp \ www \ creacion \ _admin \ gestionimagen.php on line 29 Call Stack # TimeMemoryFunctionLocation 10.0009371888 {main} () .. \ gestionimagen.php : 0 "/>

este es el codigo del onclick flotante

<body>

<?php if ((isset($_POST["enviado"])) && ($_POST["enviado"] == "form1")) {
$nombre_archivo = $_FILES['userfile']['name'];
move_uploaded_file($_FILES['userfile']['tmp_name'],"../documentos/productos".$nombre_archivo);
?>
<script>
opener.document.form1.<?php echo $_POST["nombrecampo"]; ?>.value="<?php echo $nombre_archivo; ?>";
self.close();
</script>
<?php
}
else
{?>

<form action="gestionimagen.php" method="post" enctype= "multipart/form-data" id="form1" name="form1">
<p>
<input name="userfile" type="file" />
</p>
<p>
<input type="submit" name="button" id="button" value="Subir Imagen" />
</p><input name="nombrecampo" type="hidden" value="<?php echo $_GET["campo"]; ?>" />
<input type="hidden" name="enviado" value="forml" />
</form>
<?php }?>
</body>
</html>

gracias ;)
  #2 (permalink)  
Antiguo 19/09/2012, 12:52
 
Fecha de Ingreso: agosto-2012
Mensajes: 601
Antigüedad: 11 años, 8 meses
Puntos: 83
Respuesta: Problema al subir un archivo al servidor

Lo que dice el error es que $_GET['campo'] no existe; comprueba que la url con la que trabaja este script lleva una query con una clave-valor del tipo:

Código:
direccion_url.com/cosas/archivo.php?campo=datocampo

O bien implementa algun tipo de control de errores con un simple 'isset' para detener el script antes de que se produzca el error y a la vez arrojar un mensaje de alerta.

vosk
  #3 (permalink)  
Antiguo 19/09/2012, 13:24
Avatar de ricky0123456  
Fecha de Ingreso: septiembre-2012
Ubicación: Caracas
Mensajes: 25
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: Problema al subir un archivo al servidor

Hola vosk
muchas garcías por tu respuesta, como puedes ver soy bastante nuevo en esto y la mayoría de cosas me suenan aun entrañas,

te adjunto código de donde esta el formulario

<script>
function subirimagen(nombrecampo)
{
self.name = 'opener';
remote = open('gestionimagen.php?campo='+nombrecampo, 'remote', "toolbar=no,menubar=no,directories=no,status=no,re sizable=yes,location=no,scrollbars=no,height=300,w idth=300,screenX=10,screenY=50")
remote.focus()
}

</script>


<h1>A&ntilde;adir Publicidad</h1>
<p>&nbsp;</p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td width="193" align="right" nowrap="nowrap"><h3>Imagen Grande(734x250 px):</h3></td>
<td width="240"><input type="text" name="strImagenGrande" value="" size="32" />
<input type="button" name="button" id="button" value="Subir imagen" onclick="javascript:subirimagen('strImagenGrande') ;" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> <h3>Imagen Peque&ntilde;a (80x50 px):</h3></td>
<td><input type="text" name="strImagenPequenya" value="" size="32" />
<input type="button" name="button2" id="button2" value="Subir imagen" onclick="javascript:subirimagen('strImagenPequenya ');" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><h3>Titulo:</h3></td>
<td><input type="text" name="strTitulo" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><h3>Sub Titulo:</h3></td>
<td><input type="text" name="strSubTitulo" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><h3>Menu:</h3></td>
<td><input type="text" name="strMenu" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><h3>Link:</h3></td>
<td><input type="text" name="strlink" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><h3>Orden:</h3></td>
<td><input type="text" name="intOrden" value="" size="5" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><h3>Estado:</h3></td>
<td><label for="inStado"></label>
<select name="inStado" id="inStado">
<option value="1">Activado</option>
<option value="o">Desactivado</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><h3>&nbsp;</h3></td>
<td><input type="submit" value="Aceptar" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
  #4 (permalink)  
Antiguo 19/09/2012, 13:32
Avatar de ricky0123456  
Fecha de Ingreso: septiembre-2012
Ubicación: Caracas
Mensajes: 25
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: Problema al subir un archivo al servidor

Estoy trabajando en localhost..
gracias por tu paciencia

Etiquetas: html, input, servidor
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

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 02:55.