Guest User

download

a guest
Dec 18th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "";
  6. $dbname = "docbox";
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11. die("Connection failed: " . $conn->connect_error);
  12. }
  13. session_start();
  14. $currentfile=$_SESSION['currentfileid'];
  15. $query ="SELECT name,data,mime FROM filedatabase WHERE id=$currentfile ";
  16. $result=$conn->query($query);
  17.  
  18. if ($result->num_rows > 0) {
  19. $row = $result->fetch_assoc();
  20.  
  21. $imageData=$row['data'];
  22. $imageType=$row['mime'];
  23. $filename=$row['name'];
  24.  
  25. header("Content-disposition: attachment; filename=$filename");
  26. header("content-type:application/octet-stream");
  27.  
  28. die($imageData);
  29. // echo $imageData;
  30. }
  31. ?>
Add Comment
Please, Sign In to add comment