Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2010
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2.     define('DIR_DOWNLOAD','../arquivos/');
  3.     $arquivo = $_GET['arquivo'];
  4.    
  5.  
  6.  
  7.     if(stripos($arquivo, './') !== false || stripos($arquivo, '../') !== false){
  8.         exit('Operação DOWNLOAD inválida');
  9.     }
  10.     $arquivo = DIR_DOWNLOAD.$arquivo;
  11.     if(!file_exists($arquivo)){
  12.         exit('Operação DOWNLOAD inválida');
  13.     }  
  14.        
  15.     header('Content-type: octet/stream');
  16.     header('Content-disposition: attachment; filename="'.basename($arquivo).'";');
  17.     header('Content-Length: '.filesize($arquivo));
  18.     readfile($arquivo);
  19.     exit;
  20.  
  21.  
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement