我正在尝试显示图像,尽管我在服务器中获得了正确的图像URL,但它什么也没显示。这是我当前的进度/ 输出:
PHP代码段
$Report_ID = 51;
$Retrieval_Image_Query = mysqli_query($Connection, "SELECT Image_Name,Original_Image_Directory,RGB_Image_Directory FROM Report_Image WHERE Report_ID = $Report_ID");
//REMOVES THE FOLLOWING WORDS IN THE STRING BECAUSE IT RESULTS IN A WRONG URL
$Result = mysqli_fetch_object($Retrieval_Image_Query);
$Temp_Orig_Image = str_replace("/home/u871055686/domains/", '', $Result->Original_Image_Directory);
$Temp_RGB_Image = str_replace("/home/u871055686/domains/", '', $Result->RGB_Image_Directory);
$Final_String["Original_Image_Directory"] = preg_replace("/\bpublic_html\b/", '', $Temp_Orig_Image);
$Final_String["RGB_Image_Directory"] = preg_replace("/\bpublic_html\b/", '', $Temp_RGB_Image);
$Final_String["Image_Name"] = $Result->Image_Name;
?>
<img src = "<?php echo $Final_String["Original_Image_Directory"]; ?>" width = "250" height = "250" alt = "Working"/>
<?php
echo "<pre>";
var_dump($Final_String);
echo "</pre><br>";
echo json_encode($Final_String);
它输出以下URL:fireoutph.com//Report_Images/Orig_Nov_2,_2018_9:33:20_PM.png
但是,当我尝试在网络浏览器(谷歌浏览器)中打开该链接时,它显示的图像文件没有问题。注意URL中的双斜杠。
问题
如果图像路径和文件类型的数据检索没有问题,可能是什么问题?和如何成功显示图像?
答案 0 :(得分:1)
在图像网址之前添加http://
:
http://fireoutph.com//Report_Images/Orig_Nov_2,_2018_9:33:20_PM.png