note 94508 added to function.header

From: Date: Mon, 09 Nov 2009 18:06:42 +0000
Subject: note 94508 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-162670@lists.php.net to get a copy of this message
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); ?> ---- Server IP: 187.16.23.134 Probable Submitter: 201.16.160.129 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- https://master.php.net/note/edit/94508 Del: integrated -- https://master.php.net/note/delete/94508/integrated Del: useless -- https://master.php.net/note/delete/94508/useless Del: bad code -- https://master.php.net/note/delete/94508/bad+code Del: spam -- https://master.php.net/note/delete/94508/spam Del: non-english -- https://master.php.net/note/delete/94508/non-english Del: in docs -- https://master.php.net/note/delete/94508/in+docs Del: other reasons-- https://master.php.net/note/delete/94508 Reject -- https://master.php.net/note/reject/94508 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#162670) next »