note 94508 deleted from function.header by danbrown

From: Date: Mon, 09 Nov 2009 18:08:26 +0000
Subject: note 94508 deleted from function.header by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162671@lists.php.net to get a copy of this message
Note Submitter: leomm02 - Leonardo Mazarao Michel ---- To force the download file, use: <?php // header("location: http://192.168.23.61/nfeautoriz/"); // Define o tempo máximo de execução em 0 para as conexões lentas // Define the max time of the excution in 0 to slow connections set_time_limit(0); // Aqui você faz as validações e/ou pega os dados do banco de dados // Here you define the validations or catch the data of the database $arquivo = $_POST['chave']; // 'imagem.jpg'; // nome do arquivo que será enviado p/ download $caminho = 'arqs/' . $arquivo . '-procNFe.xml'; // caminho absoluto do arquivo // echo $caminho . '<br />'; // debug // Verifica se o arquivo não existe / verify if file exists if ( !file_exists($caminho) ) { // Exiba uma mensagem de erro caso ele não exista // Message Error echo 'Desculpe, arquivo não existente em nossa base de dados...'; }else{ // Definimos o novo nome do arquivo // defining the new file name $novoNome = $arquivo . '.xml'; // 'imagem_nova.jpg'; // Configuramos os headers que serão enviados para o browser // set the headers that will be send to browser header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename="'.$novoNome.'"'); // header('Content-Type: application/octet-stream'); header('Content-Type: application/download'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($caminho)); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Expires: 0'); // Envia o arquivo para o cliente // Send the file to the client readfile($caminho); ?>

« previous php.notes (#162671) next »