2014-02-22 83 views
0

Iam無法在網頁中顯示jp2圖像。從mysql數據庫獲取jp2圖像並使用php顯示在網頁中

這是從數據庫中獲取圖像並將其顯示到網頁中的主要文件。

數據庫中的圖像格式爲JP2圖像格式。

 <?php 
     echo' <html>'; 
     echo'<body>'; 
     echo' <table>'; 
     echo' <tr><td>'; 

     $dbcnx = @mysql_connect('127.0.0.1', 'root', '[email protected]'); 
     if (!$dbcnx) { 
      die('<p>Unable to connect to the ' . 'database server at this time.</p>' 
     ); 
      } 
     if ([email protected]_select_db('finaldb')) { 
       die('<p>Unable to locate the ' . 'database at this time.</p>'); 
      } 

       $selectrc = 'select BPFT_Photo from photo_templates limit 1'; 
       $result = @mysql_query($selectrc, $dbcnx); 
      if (!$result) { 
       die('<p>Error performing query: ' . mysql_error() . '</p>'); 
       } else { 

      } 
     $n = mysql_num_rows($result); 

      $row = mysql_fetch_assoc($result); 

       $Photo_Details = $row['BPFT_Photo']; 

      $residentPhoto = getResidentPhoto(); 
      $image_type_to_mime_type0 =image_type_to_mime_type($residentPhoto) 
      header('Content-type:$image_type_to_mime_type0'); 

      echo' '.$residentPhoto; 

      echo'</td>'; 
      echo'</tr>'; 
      echo'</table>'; 
      echo'</body>'; 
      echo'</html>'; 
      ?> 

回答

0

JP2圖像必須支持的瀏覽器或您無法看到..

,你用什麼方法將其添加到網頁

(我想你使用的回聲),但回聲會沒事做只能寫一些charecters到網頁

必須從數據庫中獲取的圖像,並將其保存在服務器中的臨時文件夾和回聲路徑網絡

例如:

$path="root/tmp/photo.jp2"; 
echo '<img src=$path>'; 
0
Remember that header() must be called before any actual output is sent 

上述行來自php.net。 您正在使用標題請求,但您已經回覆了一些數據,因此標題已經發送。

如果你想顯示JP2數據,你有兩個選擇:

  • 閱讀從數據庫中的數據,然後創建一個臨時文件(比如file_put_contents,然後用加載圖像。 <img>標籤。
  • 使用除JP2原始數據header(Content-type)方法,但僅outputing的圖像數據,而不表和其它。

UPDATE:

也期待here有關JPEG-2000格式的非常微小支持下,經過一年又一年。我會改變我的想法JP2使用在網絡上,如果我是你..

相關問題