Guest User

Untitled

a guest
Sep 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. DIsplay image(bytea) from postgresql with php
  2. $conn = pg_pconnect("dbname=test user=postgres password=postgres");
  3.  
  4. $temp = '/home/postgres/tmp.jpg';
  5.  
  6. $query = "select lo_export(image, '$temp') from map ";
  7. $result = pg_query($query);
  8.  
  9. if($result)
  10. {
  11. while ($line = pg_fetch_array($result))
  12. {
  13. $ctobj = $line["image"];
  14. echo "<IMG SRC=show.php> </br>";
  15.  
  16. }
  17.  
  18. }
  19. else { echo "File does not exists."; }
  20. pg_close($conn);
  21.  
  22. header("Content-type: image/jpeg");
  23. $jpeg = fopen("/home/postgres/tmp.jpg","r");
  24. $image = fread($jpeg,filesize("/home/postgres/tmp.jpg"));
  25. echo $image;
Add Comment
Please, Sign In to add comment