draw62188 2016-04-13 17:02
浏览 110
已采纳

PHP在另一台服务器上执行PHP并获得结果

My shared hosting does not support postgresql php functions, but I need to load some images from postgresql which is hosted remotely on a dedicated server.

Would it be possible to have a PHP script on the server with postgresql and then another PHP script on the shared hosting would call the script on the postgresql server to get the images from the dedicated server to the shared hosting but I don't want the IP or domain of the dedicated server ever to be revealed.

Would this be possible? if so how?

  • 写回答

4条回答 默认 最新

  • donglianer5064 2016-04-13 17:17
    关注

    it's even much easier with file_get_contents():

    $img_binary = file_get_contents("https://i.imgur.com/1H9Ht5a.png");
    $img_base64 = base64_encode($img_binary);
    echo '<img src="data:image/png;base64,' . $img_base64 . '">';
    

    plus: it's a standard PHP method where "cURL" might not be activated in every PHP environment.

    be careful with the type of your image. replace data:image/png; with data:image/jpeg; or other image formats accordingly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?