Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/10/2008, 09:18
Avatar de SpiderNet
SpiderNet
 
Fecha de Ingreso: agosto-2008
Ubicación: Venezuela
Mensajes: 29
Antigüedad: 15 años, 8 meses
Puntos: 0
subir archivos con PHP y funcion javascript no funcionan

Quiero subir archivos al servidor a traves de un formulario.

Quiero ademas tener una función javascript que no me permita dejar campos en blanco.

La parte de subir el archivo funciona perfectamente.

Pero no me funciona la funcion de javascript

Código:
<!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" />
<title>Subir Archivos</title>
</head>

<body>

	    <script type="text/javascript">
<!--
	      function checkForm(formu)
	      {
		    var error=false;
		    var mensaje="";
		
		    formu.btnAdd.disabled=true;
		    if (formu.formTitulo.value=="")
		    {
			  mensaje += '· Debe seleccionar una valor1\n';
			  error=true;
		    }
            if (error)
		    {
			  alert(mensaje);
			  formu.btnAdd.disabled=false;
			  return false;
		    }
		    else
		    {
			  return true;
		    }
	      }
-->
</script>

<?
	if (isset($_POST['submit'])) 
	{  
		  if(is_uploaded_file($_FILES['fichero']['tmp_name'])) 
		  { 
				// verifica haya sido cargado el archivo 
				if(move_uploaded_file($_FILES['fichero']['tmp_name'], $_FILES['fichero']['name'])) 
				{ 
					  // AQUI VA EL PROCESO DE GRABAR EN LA BASE DE DATOS EL RESTO DE LOS CAMPOS 
					  echo "<b>Upload exitoso!. Datos:</b><br>"; 
				} 
		  }
	}
?>

<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" onSubmit="return checkForm(this);">
  <table>
    <tr>
      <td>
        Archivo: <input name="fichero" type="file">
      </td>
    </tr>
    <tr>
      <td>Titulo: <input type="text" name="formTitulo" value="" size="36"></td>
    </tr>
    <tr>
      <td>
        <input name="submit" type="submit" value="Upload!">
      </td>
    </tr>
  </table>  
</form> 

</body>

</html>
Donde esta el error ?

Última edición por SpiderNet; 07/10/2008 a las 13:10