Eduneri 0 Denunciar post Postado Maio 16, 2008 E aí galera, beleza? Gostaria de saber se alguém sabe alguma coisa sobre sobre como fazer o download de um .pdf sem que abra o browser... somente faça o download. Um grande abraço Compartilhar este post Link para o post Compartilhar em outros sites
andreymor 0 Denunciar post Postado Maio 16, 2008 ta usando o FPDF??? se estiver..... ao fazer o output, coloca F para mais referencias: http://www.fpdf.org/ F: save to a local file with the name given by name. Att., Andrey Moretti Compartilhar este post Link para o post Compartilhar em outros sites
Eduneri 0 Denunciar post Postado Maio 17, 2008 Deixa eu explicar melhor... Tem o arquivo .pdf no servidor, daí o usuário ao clicar, gostaria que ele fizesse o download ao invés do browser abrir o arquivo para ele. Isto é possível? Grande abraço, Compartilhar este post Link para o post Compartilhar em outros sites
Beraldo 864 Denunciar post Postado Maio 17, 2008 Exemplo #1 Download dialog If you want the user to be prompted to save the data you are sending, such as a generated PDF file, you can use the » Content-Disposition header to supply a recommended filename and force the browser to display the save dialog. <?php // We'll be outputting a PDF header('Content-type: application/pdf'); // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="downloaded.pdf"'); // The PDF source is in original.pdf readfile('original.pdf'); ?> Fonte: http://br2.php.net/header http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif []s Beraldo Compartilhar este post Link para o post Compartilhar em outros sites
Eduneri 0 Denunciar post Postado Maio 29, 2008 Intaum Beraldo... Coloquei a função header como você explico, porém qdo faz o download o arquivo vem corrompido... já se peço simplesmente abrir pelo browser e depois salvá-lo na maquina, fica certinho o arquivo... o que vcs acham q pode estar acontecendo: <? $id = $_GET['id']; $artigo = $id.".pdf"; header('Content-type: application/pdf'); header("Content-Disposition: attachment; filename=".basename($artigo).";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($artigo)); readfile('original.pdf'); ?> Obrigado pela ajuda pessoal Compartilhar este post Link para o post Compartilhar em outros sites
visitante_php 0 Denunciar post Postado Maio 29, 2008 experimenta retirar a linha encoding binary.... Compartilhar este post Link para o post Compartilhar em outros sites
Eduneri 0 Denunciar post Postado Maio 29, 2008 Já havia tentando... porém tentei novamente devido a sua opinião... porém tbém não deu certo... Obrigado pela ajuda!!!! Compartilhar este post Link para o post Compartilhar em outros sites
Eduneri 0 Denunciar post Postado Maio 30, 2008 Alguém?????????? Compartilhar este post Link para o post Compartilhar em outros sites
visitante_php 0 Denunciar post Postado Maio 31, 2008 cara, eu testei aki esse codigo <?php // We'll be outputting a PDF header('Content-type: application/pdf'); // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="downloaded.pdf"'); // The PDF source is in original.pdf readfile('original.pdf'); ?> e ele pediu pra baixar normalmente...experimenta copiar o codigo da pagina do header so mudando o nome do arquivo... Compartilhar este post Link para o post Compartilhar em outros sites
hinom 5 Denunciar post Postado Maio 31, 2008 <?php $base_dir = realpath( '.' ); $str = '\\'; strpos( $base_dir, $str ) ? $base_slash = $str : $base_slash = "/"; $fileName = 'arquivo.pdf'; $fileLocalPath = $base_dir . $base_slash . $fileName; $fileSize = filesize( $fileLocalPath ); header("Content-Type: application/force-download"); header("Content-Length: " . $fileSize ); header("Content-disposition: filename=" . $fileName ); header("Pragma: no-cache"); header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); header("Expires: 0"); readfile( $fileLocalPath ); ?> Compartilhar este post Link para o post Compartilhar em outros sites
Eduneri 0 Denunciar post Postado Junho 9, 2008 E aí galera, beleza? Mais uma vez eu encomodando vcs novamente... Não deu certo... eu tento fazer o download, ele faz, porém o arquivo fica corrompido... e se pedir para abrir no brownser, funciona certinho... o q será? o código q useri foi: <? $id = $_GET['id']; $base_dir = realpath( '.' ); $str = '\\'; strpos( $base_dir, $str ) ? $base_slash = $str : $base_slash = "/"; $fileName = $id.'.pdf'; $fileLocalPath = $base_dir . $base_slash . $fileName; $fileSize = filesize( $fileLocalPath ); header("Content-Type: application/force-download"); header("Content-Length: " . $fileSize ); header("Content-disposition: filename=" . $fileName ); header("Pragma: no-cache"); header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); header("Expires: 0"); readfile( $fileLocalPath ); ?> Muito obrigado pela ajuda... Compartilhar este post Link para o post Compartilhar em outros sites
hinom 5 Denunciar post Postado Junho 9, 2008 faça um debug antes do header // for debug echo '<br>filename: ' . $fileName; echo '<br>fileLocalPath : ' . $fileLocalPath; echo '<br>fileSize : ' . $fileSize; exit; // interrompe o script header("Content-Type: application/force-download"); header("Content-Length: " . $fileSi ... faça o teste e poste aqui o resultado. Compartilhar este post Link para o post Compartilhar em outros sites