Ver Mensaje Individual
  #3 (permalink)  
Antiguo 20/09/2012, 10:16
truchito
 
Fecha de Ingreso: agosto-2010
Ubicación: Barcelona
Mensajes: 22
Antigüedad: 13 años, 8 meses
Puntos: 0
Respuesta: Filesize no me funciona

Solucionado!

el código final fue!

Código PHP:
Ver original
  1. <?php
  2.     session_start();
  3.     if(isset($_SESSION["variables_form"]) && isset($_SESSION["variables_form_dw"]) && isset($_REQUEST["so"]) && isset($_REQUEST["file"])){  
  4.         $variables_form = $_SESSION["variables_form_dw"];
  5.         $variables_form["so"] = $_REQUEST["so"];
  6.  
  7.         $_SESSION["variables_form_dw"] = $variables_form;
  8.          $name = stripslashes(strip_tags($variables_form["nombre"]))." ".stripslashes(strip_tags($variables_form["apellidos"]));
  9.         $apellidos = stripslashes(strip_tags($variables_form["apellidos"]));
  10.          $empresa = stripslashes(strip_tags($variables_form["empresa"]));
  11.         $telefono = stripslashes(strip_tags($variables_form["telefono"]));
  12.         $mail = stripslashes(strip_tags($variables_form["mail"]));
  13.         $npeces = stripslashes(strip_tags($variables_form["npces"]));
  14.         $producto = stripslashes(strip_tags($variables_form["producto"]));
  15.         $sistema = stripslashes(strip_tags($variables_form["so"]));
  16.        
  17.         $ip .= "". $_SERVER['REMOTE_ADDR'] ."";
  18.        
  19.         $headers_fromUser = "From: ".$name."\r\n";
  20.         $headers_fromUser.= "Reply-To: ".$mail."\r\n";
  21.         $headers_fromUser.= "MIME-Version: 1.0\r\n";
  22.         $headers_fromUser.= "Content-Type: text/html; charset=UTF-8\r\n";
  23.        
  24.         $message = "IP: ".$ip."<br /> Nombre: ".$name."<br />Apellidos: ".$apellidos."<br />Empresa: ".$empresa."<br />Teléfono: ".$telefono."<br />Email: ".$mail."<br />Nº PCs: ".$npeces."<br />Producto: ".$producto."<br />Sistema: ".$sistema;
  25.    
  26.         $send = @mail("Totem Guard"." <[email protected]>\r\n","Descarga de software", $message, $headers_fromUser);
  27.  
  28.             $url = $_REQUEST["file"];
  29.            
  30.             $file = basename($url);        
  31.             $head = get_headers($url, 1);
  32.             $size = $head['Content-Length'];       
  33.             $mime = array('application/octet-stream');
  34.            
  35.             header('Content-Type: '.$mime);
  36.             header('Content-Disposition: attachment; filename="'.$file.'"');
  37.             header('Content-Transfer-Encoding: binary');
  38.             header('Content-Length: '.$size);
  39.        
  40.             header('Expires: 0');  
  41.            
  42.             // check for IE only headers
  43.             if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
  44.                 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  45.                 header('Pragma: public');
  46.             } else {
  47.                 header('Pragma: no-cache');
  48.             }
  49.  
  50.            
  51.            
  52.     readfile($url);
  53.             if (!$send) {
  54.                
  55.                 die();
  56.             }
  57.    
  58.     }
  59.     else if(!isset($_REQUEST["producto_id"])){
  60.         $error_form = "Debe seguir todos los pasos para poder descargar el software. Debe volver a rellenar el <a href='http://www.xxx.com'>formulario</a>.";
  61.     }
  62.    
  63.    
  64. ?>