Foros del Web » Programando para Internet » PHP »

input type file pasa vacio

Estas en el tema de input type file pasa vacio en el foro de PHP en Foros del Web. Hola ¡¡ Tengo un problema con el input type="file" de un formulario. En el index.php tengo input como los siguientes: Código: <form id="contact-form" name="contact-form" method="post" ...
  #1 (permalink)  
Antiguo 09/11/2010, 10:53
 
Fecha de Ingreso: marzo-2008
Mensajes: 42
Antigüedad: 16 años
Puntos: 0
input type file pasa vacio

Hola ¡¡

Tengo un problema con el input type="file" de un formulario. En el index.php tengo input como los siguientes:

Código:
    
    <form id="contact-form" name="contact-form" method="post" enctype="multipart/form-data" action="submit.php">
<td><label for="email">Email</label></td>
          <td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td>
          <td>&nbsp;</td>
        </tr>
         <tr>
          <td><label for="telefono">Teléfono</label></td>
          <td><input type="text" class="validate[required,custom[telephone]]" name="telefono" id="telefono" value="<?=$_SESSION['post']['telefono']?>" /></td>
          <td>&nbsp;</td>
        </tr>
         <tr>
          <td><label for="archivo">Archivo</label></td>
          <td><div class="jqTransformInputWrapper" style="width: 152px;"><div class="jqTransformInputInner"><div><input type="file" class="inputFile" name="archivo" id="archivo" value="<?=$_FILES['archivo']['name']?>"/></div></div></div></td>
No se exactamente que value ponerle al input file para que funcione ya que cuando llamo al submit.php, me envía el email pero el dato de la ruta del archivo no me la muestra:

Código:
$path = $_FILES['archivo']['name'];

$msg=
Email:	'.$_POST['email'].'<br />
Archivo2:	'.$path.'<br />
Tel&eacute;fono:	'.$_POST['telefono'].'<br />
IP:	'.$_SERVER['REMOTE_ADDR'].'<br /><br />

Mensaje:<br /><br />
¿Qué value debo ponerle al input file para que me rellena la variable path con la ruta en el submit.php?

Gracias ¡¡¡¡
  #2 (permalink)  
Antiguo 09/11/2010, 11:16
Avatar de Nano_  
Fecha de Ingreso: febrero-2006
Ubicación: Bogotá, Colombia
Mensajes: 1.866
Antigüedad: 18 años, 2 meses
Puntos: 96
Respuesta: input type file pasa vacio

Saludos

Ningun value debes ponerle al input file

Código PHP:
$path=$_FILES['archivo']['tmp_name']; 
__________________
:.:Nano.:: @nano_hard - Retornando al foro
  #3 (permalink)  
Antiguo 09/11/2010, 15:47
 
Fecha de Ingreso: marzo-2008
Mensajes: 42
Antigüedad: 16 años
Puntos: 0
Respuesta: input type file pasa vacio

Cita:
Iniciado por Nano_ Ver Mensaje
Saludos

Ningun value debes ponerle al input file

Código PHP:
$path=$_FILES['archivo']['tmp_name']; 

Gracias por contestar, he probado así pero tampoco me funciona, no consigo rellenar la variable con la ruta del archivo.

Aquí está todo el código del index.php

Código:
<?php

session_name("fancyform");
session_start();


$_SESSION['n1'] = rand(1,20);
$_SESSION['n2'] = rand(1,20);
$_SESSION['expect'] = $_SESSION['n1']+$_SESSION['n2'];


$str='';
if($_SESSION['errStr'])
{
	$str='<div class="error">'.$_SESSION['errStr'].'</div>';
	unset($_SESSION['errStr']);
}

$success='';
if($_SESSION['sent'])
{
	$success='<h1>Gracias</h1>';
	
	$css='<style type="text/css">#contact-form{display:none;}</style>';
	
	unset($_SESSION['sent']);
}
?>


<!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=utf-8" />

<link rel="stylesheet" type="text/css" href="jqtransformplugin/jqtransform.css" />
<link rel="stylesheet" type="text/css" href="formValidator/validationEngine.jquery.css" />
<link rel="stylesheet" type="text/css" href="demo.css" />

<?=$css?>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="jqtransformplugin/jquery.jqtransform.js"></script>
<script type="text/javascript" src="formValidator/jquery.validationEngine.js"></script>

<script type="text/javascript" src="script.js"></script>
<script src="js/jquery.filestyle.js" type="text/javascript"></script>

<script language="javascript" type="text/javascript">
	$(function() {
		 $(".inputFile").filestyle({ 
			 image: "img/examinar.jpg", //Ruta de la imagen (botón).
			 imageheight:28, //Height de la imagen.
			 imagewidth: 68, //Widht de la imagen.
			 width: 145 //Tamaño del input.
		 });
	});
</script>

<style type="text/css" media="all">
.inputFile {
	border:none; 
	border-color:transparent; 
	background-color:transparent;
}
</style>

</head>

<body>

<div id="main-container">

	<div id="form-container">

    <h2>Drop us a line and we will get back to you</h2>
    
    <form id="contact-form" name="contact-form" method="post" enctype="multipart/form-data" action="submit.php">
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td width="15%"><label for="name">Nombre</label></td>
          <td width="70%"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="<?=$_SESSION['post']['name']?>" /></td>
          <td width="15%" id="errOffset">&nbsp;</td>
        </tr>
        <tr>
          <td><label for="email">Email</label></td>
          <td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td>
          <td>&nbsp;</td>
        </tr>
         <tr>
          <td><label for="telefono">Teléfono</label></td>
          <td><input type="text" class="validate[required,custom[telephone]]" name="telefono" id="telefono" value="<?=$_SESSION['post']['telefono']?>" /></td>
          <td>&nbsp;</td>
        </tr>
         <tr>
          <td><label for="archivo">Archivo</label></td>
          <td><div class="jqTransformInputWrapper" style="width: 152px;"><div class="jqTransformInputInner"><div><input type="file" class="inputFile" name="archivo" id="archivo" /></div></div></div></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><label for="subject">Asunto</label></td>
          <td><select name="subject" id="subject">
            <option value="" selected="selected"> - Seleccionar -</option>
            <option value="Pregunta">Pregunta</option>
            <option value="Sugerencia">Sugerencia</option>
          </select>          </td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td valign="top"><label for="message">Mensaje</label></td>
          <td><textarea name="message" id="message" class="validate[required]" cols="35" rows="5"><?=$_SESSION['post']['message']?></textarea></td>
          <td valign="top">&nbsp;</td>
        </tr>
        <tr>
          <td><label for="captcha"><?=$_SESSION['n1']?> + <?=$_SESSION['n2']?> =</label></td>
          <td><input type="text" class="validate[required,custom[onlyNumber]]" name="captcha" id="captcha" /></td>
          <td valign="top">&nbsp;</td>
        </tr>
        <tr>
          <td valign="top">&nbsp;</td>
          <td colspan="2"><dl><dt><input type="submit" name="button" id="button" value="Enviar" />
          <input type="reset" name="button2" id="button2" value="Limpiar" /></dt></dl>
          
          <?=$str?>          <img id="loading" src="img/ajax-load.gif" width="16" height="16" alt="loading" /></td>
        </tr>
      </table>
      </form>
      <?=$success?>
    </div>
</div>

</body>
</html>

Etiquetas: file, input, type, vacio
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.