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. 使用HttpModule顯示圖像
- 3. 使用xml顯示圖像
- 4. 使用php顯示圖像
- 5. 使用servlets顯示圖像
- 6. 使用Play顯示圖像
- 7. 使用html_entity_decode顯示圖像
- 8. 使用json顯示圖像
- 9. 使用jQuery顯示圖像
- 10. 顯示圖像使用jQuery
- 11. 使用SceneBuilder顯示圖像
- 12. 使用EPUBLIB顯示圖像
- 13. 使用JavaScript顯示圖像
- 14. 使用babylonjs顯示圖像
- 15. 使用C++顯示圖像
- 16. 使用file_get_contents從url中獲取圖像
- 17. 圖片不顯示使用讀取文件/ file_get_contents
- 18. 使用OpenGL顯示圖像使用SOIL
- 19. 使用散點圖顯示圖像
- 20. 使用QItemDelegate顯示圖像縮略圖
- 21. 顯示標籤:如何使用顯示標籤顯示圖像
- 22. 使用用於顯示圖像文件
- 23. 遠程圖像顯示不工作(現在用的file_get_contents和捲曲工作)
- 24. 使圖像顯示在JButton
- 25. 使圖像顯示...如何?
- 26. IE顯示破碎的圖像,'顯示圖像'使它們顯示正常
- 27. 顯示圖像顯示partialy
- 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