30
A
回答
27
我需要修改标题,只是回声它或什么?
确切地说。
发送一个header("content-type: image/your_image_type");
和之后的数据。
9
你可以做到这一点,或者你可以使用readfile
功能,输出为你:
header('Content-Type: image/x-png'); //or whatever
readfile('thefile.png');
die();
编辑:DERP,固定明显突出的错字。
55
您可以使用readfile和输出的图像头,你可以从getimagesize得到这样的:
$remoteImage = "http://www.example.com/gifs/logo.gif";
$imginfo = getimagesize($remoteImage);
header("Content-type: {$imginfo['mime']}");
readfile($remoteImage);
你应该ReadFile的使用这里的原因是,它直接将文件,其中输出到输出缓冲区file_get_contents会将文件读入内存中,这在内容中是不必要的,并且可能对大文件密集。
7
,你可以这样做:
<?php
$file = 'your_images.jpg';
header('Content-Type: image/jpeg');
header('Content-Length: ' . filesize($file));
echo file_get_contents($file);
?>
26
$image = 'http://images.itracki.com/2011/06/favicon.png';
// Read image path, convert to base64 encoding
$imageData = base64_encode(file_get_contents($image));
// Format the image SRC: data:{mime};base64,{data};
$src = 'data: '.mime_content_type($image).';base64,'.$imageData;
// Echo out a sample image
echo '<img src="' . $src . '">';
0
小编辑到@seengee答案: 为了工作,你需要周围的可变花括号,否则你会得到一个错误。
header("Content-type: {$imginfo['mime']}");
相关问题
- 1. 使用图像目录显示图像
- 2. 使用babylonjs显示图像
- 3. 使用HttpModule显示图像
- 4. 使用html_entity_decode显示图像
- 5. 使用SceneBuilder显示图像
- 6. 使用json显示图像
- 7. 图片不显示使用读取文件/ file_get_contents
- 8. 使用OpenGL显示图像使用SOIL
- 9. 使用QItemDelegate显示图像缩略图
- 10. 使用散点图显示图像
- 11. 显示标签:如何使用显示标签显示图像
- 12. 使用用于显示图像文件
- 13. 使图像显示...如何?
- 14. 使图像显示在JButton
- 15. 显示图像显示partialy
- 16. 显示图像
- 17. 显示图像
- 18. 显示图像
- 19. 显示图像
- 20. 显示图像
- 21. 图像显示
- 22. 显示图像
- 23. 显示图像
- 24. 显示图像
- 25. 显示图像
- 26. 显示图像
- 27. 显示图像
- 28. 显示图像
- 29. 显示图像
- 30. 显示图像
正常的,和报头( “内容类型:image/JPG”); 应该足够吗? – 2010-11-26 15:51:42
@Belgin如果它是JPG图像,是的。 – 2010-11-26 15:52:16
是否需要图像/ jpeg? – Rahly 2010-11-26 16:26:16