Foros del Web » Programando para Internet » PHP »

Funciona en todos lados menos en Explorer

Estas en el tema de Funciona en todos lados menos en Explorer en el foro de PHP en Foros del Web. Hola a todos, me encontré este foro y ojalá me puedan ayudar. Este es mi primer mensaje y no sé nada de PHP, lo puedo ...
  #1 (permalink)  
Antiguo 10/09/2008, 16:01
 
Fecha de Ingreso: septiembre-2008
Mensajes: 6
Antigüedad: 15 años, 7 meses
Puntos: 0
Funciona en todos lados menos en Explorer

Hola a todos, me encontré este foro y ojalá me puedan ayudar. Este es mi primer mensaje y no sé nada de PHP, lo puedo interpretar un poco y le ando haciendo unas modificaciones a un script para que pueda enviar archivos. Al comienzo no podía enviar imagenes, pero le agregué unas cosas que eran algo así

Código:
if($strresume_type=="application/octet-stream" or $strresume_type=="text/plain" or $strresume_type=="application/msword" or $strresume_type=="image/jpeg" or $strresume_type=="image/bmp" or $strresume_type=="image/gif" or $strresume_type=="image/jpeg")
    {
Y funcionó, me enviaba correos con imágenes adjuntas siempre y cuando no lo probara con explorer.

El script es el siguiente, a ver si alguien encuentra la solución.


formulario.php
Código:
<?php
     
                     
       $strname=ucfirst($_REQUEST["strname"]);
    $straddress=ucfirst($_REQUEST["straddress"]);
    $strcity=ucfirst($_REQUEST["strcity"]);
    $strstate=ucfirst($_REQUEST["strstate"]);  
         
       
       $phone=$_REQUEST["strno"];
       if($phone != ""){ $strno=$phone; } else { $strno="-"; }   
       
    $stremail=$_REQUEST["stremail"];   
    $strcomments=ucfirst($_REQUEST["strcomments"]);

   
    $strresume_name=$_FILES["strresume"]["name"];
    $strresume_type=$_FILES["strresume"]["type"];
    $strresume_size=$_FILES["strresume"]["size"];
    $strresume_temp=$_FILES["strresume"]["tmp_name"];


       
    if($strresume_type=="application/octet-stream" or $strresume_type=="text/plain" or $strresume_type=="application/msword" or $strresume_type=="image/jpeg" or $strresume_type=="image/bmp" or $strresume_type=="image/gif" or $strresume_type=="image/jpeg")
    {
   
        $message= '
   
   
            <table cellspacing="0" cellpadding="8" border="0" width="400">
            <tr>
                <td colspan="2"></td>
            </tr>
            <tr bgcolor="#eeeeee">
                <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Name</strong></td>
                <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strname.'</td>
            </tr>
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Address</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$straddress.'</td>
              </tr>
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>City</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strcity.'</td>
              </tr>
              <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>State</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strstate.'</td>
              </tr>
              <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Contact No.</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strno.'</td>
              </tr>
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
                <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Email</strong></td>
                <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$stremail.'</td>
            </tr>
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
           
            <tr bgcolor="#eeeeee">
                <td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Comments</strong></td>
            </tr>               
            <tr bgcolor="#eeeeee">
                <td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strcomments.'</td>
            </tr>               
                                   
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
         </table>


           

';

    // MAIL SUBJECT


    $subject = "Mail with doc file attachment";
   
    // TO MAIL ADDRESS
   
   
    $to="[email protected]";

/*
    // MAIL HEADERS
                       
    $headers  = "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\n";
    $headers .= "From: Name <[email protected]>\n";

*/
 


    // MAIL HEADERS with attachment

    $fp = fopen($strresume_temp, "rb");
    $file = fread($fp, $strresume_size);

    $file = chunk_split(base64_encode($file));
    $num = md5(time());
   
        //Normal headers

    $headers  = "From: yourname<[email protected]>\r\n";
       $headers  .= "MIME-Version: 1.0\r\n";
       $headers  .= "Content-Type: multipart/mixed; ";
       $headers  .= "boundary=".$num."\r\n";
       $headers  .= "--$num\r\n";

        // This two steps to help avoid spam   

    $headers .= "Message-ID: <".gettimeofday()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n";
    $headers .= "X-Mailer: PHP v".phpversion()."\r\n";         

        // With message
       
    $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
       $headers .= "Content-Transfer-Encoding: 8bit\r\n";
       $headers .= "".$message."\n";
       $headers .= "--".$num."\n"; 

        // Attachment headers

    $headers  .= "Content-Type:".$strresume_type." ";
       $headers  .= "name=\"".$strresume_name."\"r\n";
       $headers  .= "Content-Transfer-Encoding: base64\r\n";
       $headers  .= "Content-Disposition: attachment; ";
       $headers  .= "filename=\"".$strresume_name."\"\r\n\n";
       $headers  .= "".$file."\r\n";
       $headers  .= "--".$num."--";

   
   
    // SEND MAIL
       
       @mail($to, $subject, $message, $headers);
   

     fclose($fp);

    echo '<font style="font-family:Verdana, Arial; font-size:11px; color:#333333; font-weight:bold">Yeah chamaco!!<br /></font>';
}
else
    {
        echo '<font style="font-family:Verdana, Arial; font-size:11px; color:#F3363F; font-weight:bold">Mal.</font>';
        //echo "<script>window.location.href='formulario.html';</script>";
    }

?>
  #2 (permalink)  
Antiguo 10/09/2008, 16:02
 
Fecha de Ingreso: septiembre-2008
Mensajes: 6
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Funciona en todos lados menos en Explorer

el archivo .html está acá
formulario.html
Código:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


<title>Untitled Document</title>
</head>

<body style="padding:3px; margin:0px;" bgcolor="#FFFFFF">
<table cellpadding="0" cellspacing="0" border="0" width="440">
   
    <tr><td style="height:10px"></td></tr>
    <tr>
      <td colspan="2" style="text-align:justify; line-height:15px;" class="body">
       
      <form name="frm" method="POST" action="formulario.php" enctype="multipart/form-data">
      <table cellpadding="0" cellspacing="0" border="0" width="100%">
          <tr>
            <td width="23%" class="body"> Name</td>
            <td width="3%" class="body">:</td>
            <td width="74%"><input type="text" name="strname" class="textfield"></td>
        </tr>
        <tr><td style="height:3px"></td></tr>
        <tr>
            <td width="23%" class="body"> Address</td>
            <td width="3%" class="body">:</td>
            <td width="74%"><textarea cols="16" name="straddress"></textarea></td>
        </tr>
        <tr><td style="height:3px"></td></tr>
        <tr>
            <td width="23%" class="body"> City</td>
            <td width="3%" class="body">:</td>
            <td width="74%"><input type="text" name="strcity" class="textfield"></td>
        </tr>
        <tr><td style="height:3px"></td></tr>
        <tr>
            <td width="23%" class="body"> State</td>
            <td width="3%" class="body">:</td>
            <td width="74%"><input type="text" name="strstate" class="textfield"></td>
        </tr>
        <tr><td style="height:3px"></td></tr>
        <tr>
            <td width="23%" class="body"> Contact No</td>
            <td width="3%" class="body">:</td>
            <td width="74%"><input type="text" name="strno" class="textfield"></td>
        </tr>
        <tr><td style="height:3px"></td></tr>
        <tr>
            <td width="23%" class="body"> Email</td>
            <td width="3%" class="body">:</td>
            <td width="74%"><input type="text" name="stremail" class="textfield"></td>
        </tr>
        <tr><td style="height:3px"></td></tr>
        <tr>
            <td width="23%" class="body"> Comments</td>
            <td width="3%" class="body">:</td>
            <td width="74%"><textarea cols="16" name="strcomments"></textarea></td>
        </tr>
        <tr><td style="height:3px"></td></tr>
        <tr>
            <td width="23%" class="body"> Resume</td>
            <td width="3%" class="body">:</td>
            <td width="74%"><input type="file" name="strresume"></td>
        </tr>
        <tr><td style="height:10px"></td></tr>
        <tr>
            <td colspan="3" align="center">
                <input type="submit" value="Send" name="submit" onClick="return validate();"> <input type="reset" value="Reset" name="reset">
            </td>
        </tr>
       
      </table>   
     </form>

</td>
    </tr>
    <tr>
      <td colspan="2" align="center"> </td>
  </tr>
    </table>
</body>
</html>
  #3 (permalink)  
Antiguo 13/09/2008, 14:15
 
Fecha de Ingreso: septiembre-2008
Mensajes: 6
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Funciona en todos lados menos en Explorer

vuelvo a escribir para revivir el tema, necesito que me ayuden
  #4 (permalink)  
Antiguo 14/09/2008, 16:26
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Funciona en todos lados menos en Explorer

Hola fisho,

Lo que te recomendaría es usar solamente PHPMailer para enviar los archivos de forma correcta.

Saludos.
  #5 (permalink)  
Antiguo 19/09/2008, 12:53
 
Fecha de Ingreso: septiembre-2008
Mensajes: 6
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Funciona en todos lados menos en Explorer

y con PHPMailer podré adjuntar archivos y toda la cosa?
gracias por responder :)
  #6 (permalink)  
Antiguo 19/09/2008, 13:12
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Funciona en todos lados menos en Explorer

Asi es, revisa en su web y podras ver todas sus caracteristicas.

Saludos.
  #7 (permalink)  
Antiguo 19/09/2008, 19:01
Avatar de Covids0020  
Fecha de Ingreso: septiembre-2003
Ubicación: España
Mensajes: 217
Antigüedad: 20 años, 6 meses
Puntos: 1
Respuesta: Funciona en todos lados menos en Explorer

Off Topic: Otra cosa, para ir cogiendo cosillas, mi sugerencia:

En vez de esto:
Código PHP:
if ( $strresume_type=="application/octet-stream" or 
$strresume_type=="text/plain" or $strresume_type=="application/msword" or 
$strresume_type=="image/jpeg" or $strresume_type=="image/bmp" or 
$strresume_type=="image/gif" or $strresume_type=="image/jpeg" 
Podrías usar un array contenedor de las opciones permitidas y comprobar si es una de ellas:

Código PHP:
(array) $allowedTypes = array('application/octet-stream''text/plain'/*etc*/);

if ( 
in_array($strresume_type$allowedTypes) ) {
    
// #Run...

- in_array()

Un saludo.
__________________
"La sabiduría comienza donde acaba el conocimiento". Yaris.
http://www.culturadigital.org
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 06:39.