Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wyświetlanie zdjęcia z bazy
ssylwester
post
Post #1





Grupa: Zarejestrowani
Postów: 27
Pomógł: 2
Dołączył: 18.05.2010

Ostrzeżenie: (0%)
-----


Mam zapisane zdjęcia w bazie MSSQL. Pobieram je w ten sposób
  1. <?php
  2. header('Content-type:image/jpeg');
  3. require('conf/global_conf.inc');
  4. require('./functions.php');
  5. // setup database connection
  6. $dbserver = $config['sql']['hostname'];
  7. $dbuser = $config['sql']['dbusername'];
  8. $dbpassword = $config['sql']['dbpassword'];
  9. $dbname = $config['sql']['dbname'];
  10.  
  11. @ini_set("mssql.textsize",2147483647);
  12. @ini_set("mssql.textlimit",2147483647);
  13. // connect to the sql server
  14. if(!@mssql_connect($dbserver,$dbuser,$dbpassword)){
  15. exit("<strong>Error while connecting to database.</strong>");
  16. }
  17. else {
  18. mssql_select_db($dbname);
  19. $sql = "SET TEXTSIZE 2147483647";
  20. @mssql_query($sql);
  21. $sql = "SELECT TOP 1 zdjecie FROM uzytkownik where sid=".$_GET['sid']."";
  22. //echo $sql;
  23. $rs = @mssql_query($sql);
  24. if (!$rs) {
  25. exit("<strong>Error while loading data</strong>");
  26. }
  27. $rs = mssql_fetch_assoc($rs);
  28. if (strlen($rs['zdjecie'])>0){
  29. echo $rs['zdjecie'];
  30. }
  31. else{
  32. $sql = "SET TEXTSIZE 2147483647";
  33. @mssql_query($sql);
  34. $sql = "SELECT TOP 1 plik as zdjecie FROM blank_photo";
  35. $rs = @mssql_query($sql);
  36. if (!$rs) {
  37. exit("<strong>Error while loading data</strong>");
  38. }
  39. $rs = mssql_fetch_assoc($rs);
  40. if (strlen($rs['zdjecie'])>0){
  41. echo "<img src=\".".$rs['zdjecie']."\" />";
  42. }
  43. }
  44. }
  45. ?>


Jak zakomentuję:
  1. header('Content-type:image/jpeg');


to wyświetla mi się
  1. �����JFIF�������>CREATOR: gd-jpeg v1.0 (using IJG JPEG v70), default quality

i dalej krzaczki. Co chyba oznacza że zdjęcie mam dobrze zapisane:
Jak odkomentuję:
  1. header('Content-type:image/jpeg');

to po wejściu na stronę wyświetla mi się tylko adres stony: http://portal/user_image.php?sid=1500


podgądałem ją w Firebugu ponieważ nie mogę wyświetlić źródła bo to przecież zdjęcie i mam coś takiego
  1. <title>user_image.php (Obrazek JPEG)</title>
  2. </head>
  3. <img alt="http://portal/user_image.php?sid=1500" src="http://portal/user_image.php?sid=1500">
  4. </body>
  5. </html>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 18:41