machalda

PHP file/pic upload - download

May 20th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. <?
  2. if(isset($_GET['f']))
  3. {
  4.     require_once 'db.php';
  5.     require_once 'banlist.php';
  6.     $upid = $_GET['f'];
  7.     $query = MySQL_Query("SELECT * FROM `files` WHERE id='$upid'") or die (mysql_error());             
  8.     while($result = mysql_fetch_array($query))
  9.     {      
  10.         $soubor="upload/".$result['url'];
  11.         $nazev=$result['nazev'];
  12.     }
  13.     $pripona = strtolower(pathinfo($soubor, PATHINFO_EXTENSION));
  14.     if(isset($nazev))   $name=$nazev;
  15.     else                $name = "justDownloaded.".$pripona;
  16.     header("Content-Description: File Transfer");
  17.     header("Content-Type: application/force-download");
  18.     header("Content-Disposition: attachment; filename=\"$name\""); //jmeno souboru po stazeni
  19.     readfile($soubor);
  20. }
  21. ?>
Add Comment
Please, Sign In to add comment