Ver Mensaje Individual
  #6 (permalink)  
Antiguo 09/05/2008, 09:30
xberni
 
Fecha de Ingreso: enero-2005
Ubicación: Barcelona (España)
Mensajes: 134
Antigüedad: 19 años, 3 meses
Puntos: 0
Re: Error formato msword en Firefox

Ahí va:


Código HTML:
<?php 
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . $_SERVER['QUERY_STRING'];
}

if ((isset($_POST['Guardar'])) && ($_POST['Guardar'] == "Enviar Solicitud")) {

    $anular = 'No';
	$error = '';
	$maxsize = '200000';

	$fichero = $_POST['fichero'];

	if ((isset($_FILES['fichero']['name']) && 
      is_uploaded_file($_FILES['fichero']['tmp_name']))) 
  	{

  		$type = basename($_FILES['fichero']['type']); echo $type;
  		$tamano = $_FILES['fichero']['size'];
  
  		if ($tamano > $maxsize)
		{
			$anular = 'Si';
			$error .= "El fichero ".$_FILES['fichero']['name']." es demasiado grande (Límite: ".($maxsize/1000)." Kb)<br>";
		}

  
	  	switch ($type) {

			//Tengo que revisar esto. En Firefox no funciona el Word
			case 'msword':  $filename = time().".doc";
			break;
			case 'pdf':  $filename = time().".pdf";
			break;
			default:				$error .= "Formato de archivo no válido: ".$_FILES['fichero']['type'];
									$anular = 'Si';
		 	break;
		 }
  

	} 
	
	if ($anular == 'No') {

		if ($filename) {
			move_uploaded_file($_FILES['fichero']['tmp_name'], "archivos/".$filename);
		}
	}
}



?>
<html>
<head>

<title>Sin titulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><form name="form1" method="post" action="<?php echo $editFormAction; ?>" enctype="multipart/form-data">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
	      <td colspan="2">
		  <? if (isset($anular) && $anular == 'Si')
		     {
		  ?>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="100" align="center"><strong><? echo $error;?></strong></td>
                </tr>
            </table>

            <?
			}
			?>
	      </td>
	    </tr>
        <tr>
          <td valign="middle" class="Ariall11GrisBold"><p>Subir archivo:</p> </td>
          <td>
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="52%" valign="middle"><input name="fichero" type="file" class="inputs" id="fichero" size="20"></td>
              </tr>
            </table>
		  </td>
        </tr>
        <tr>
          <td height="30" colspan="2">
			<table width="100%" align="left">
              <tr valign="middle">
                <td align="right" nowrap><div align="center">
                 <input name="Guardar" type="submit" class="botones" id="Guardar" value="Enviar Solicitud"></div> </td>
              </tr>
            </table>
		  </td>
        </tr>
      </table>
    </form>
    </td>
  </tr>
</table>
</body>
</html>