Php 使用restler返回图像
是否可以使用Luracast Restler返回图像?比如打电话:Php 使用restler返回图像,php,restler,Php,Restler,是否可以使用Luracast Restler返回图像?比如打电话: http://myserver.com/api/users/002/avatar 要下载png?可以使用Restler提供图像 您需要在API方法中执行以下操作 为正确的图像类型(png、jpeg等)设置内容类型标题 回显图像内容 示例 $im = imagecreatefrompng("test.png"); header('Content-Type: image/png'); imagepng($im); //th
http://myserver.com/api/users/002/avatar
要下载png?可以使用Restler提供图像 您需要在API方法中执行以下操作
- 为正确的图像类型(png、jpeg等)设置内容类型标题
- 回显图像内容
示例
$im = imagecreatefrompng("test.png"); header('Content-Type: image/png'); imagepng($im); //this sends the image as the response imagedestroy($im);
- 使用exit或die停止执行,而不是使用通常的返回结果
$im = imagecreatefrompng("test.png");
header('Content-Type: image/png');
imagepng($im); //this sends the image as the response
imagedestroy($im);