Ver Mensaje Individual
  #6 (permalink)  
Antiguo 25/03/2019, 15:45
orionce
 
Fecha de Ingreso: septiembre-2008
Mensajes: 9
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Descargar PDF al hacer submit en formulario

Cita:
Iniciado por sk0rpi0n Ver Mensaje
Hola!

Prueba esto!

Código PHP:
$file __DIR__.'/archivo.pdf'

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="FILENAME"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' filesize("$file"));
ob_clean();
flush();
readfile($file);     
exit(); 
Gracias por responder, pero sigo teniendo el mismo resultado, el archivo se carga en la página. Para el send estoy usando esta condición.

Código PHP:
      
    
if($_POST) {
        require 
'mailer/valida-catalogo.php';
        } else  {
            
$mail->Send();

            
$file __DIR__.'/../catalogos/catalogo.pdf'
            
header('Content-Description: File Transfer');
            
header('Content-Type: application/octet-stream');
            
header('Content-Disposition: attachment; filename="FILENAME"');
            
header('Content-Transfer-Encoding: binary');
            
header('Expires: 0');
            
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            
header('Pragma: public');
            
header('Content-Length: ' filesize("$file"));
            
ob_clean();
            
flush();
            
readfile($file);     
            exit();

// $mb= "<i>Gracias por descargar nuestro catálogo ". $nombre. ".<br>". "<small>Su descarga se iniciará en unos segundos. <br>Si no inicia, haz click <a href='catalogos/catalogo.pdf' download>aqui</a> para descargar el archivo</small></i>";
        
}          
    }