Advertisement
Guest User

Untitled

a guest
Apr 9th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. <?php
  2. $dbhost = '';
  3. $dbuser = '';
  4. $dbpass = '';
  5. $dbname = '';
  6.  
  7. $conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
  8. $conn->set_charset('utf8');
  9.  
  10. $id = $_GET['id'];
  11. $size = $_GET['size'];
  12.  
  13. $sql = 'SELECT * FROM image WHERE id='.$id;
  14. $result = $conn->query($sql);
  15.  
  16. if($parsed = $result->fetch_assoc()) $extension = $parsed["extension"];
  17.  
  18. // open the file in a binary mode
  19. $name = 'images/' . sprintf("%06d", $id) ."/". $size .".". $extension;
  20. $fp = fopen($name, 'rb');
  21.  
  22. // send the right headers
  23. header("Content-Type: image/png");
  24. header("Content-Length: " . filesize($name));
  25.  
  26. // dump the picture and stop the script
  27. fpassthru($fp);
  28. exit;
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement