如何在一个请求中 return 图片和文字

How can I return image and text in one request

我需要 return 两个属性 - 文本和图像在一个 api 请求中。我该怎么做?

您有两个选择:

1) Return 服务器上文件的文本和路径

2) 如果文件在受保护的文件夹中,则使用两个请求,一个用于文本,第二个用于图像

样本:

         $name = './img/ok.png';
         $fp = fopen($name, 'rb');
         header("Content-Type: image/png");
         header("Content-Length: " . filesize($name)); 
         fpassthru($fp);