php - 带有 readfile 和 file_get_contents 的损坏图像

标签 php image file-get-contents readfile

我正在尝试使用一个函数来让它工作:

<img src='login.php?image=ind_legend.jpg'>

但是我无法通过函数来​​放置图像。我后退了几步,只尝试了这部分代码:

<?php
$file = "http://localhost/sales/test.jpg";
header('Content-type: image/jpeg');
readfile($file);
?>

或者使用这个函数:

echo file_get_contents($source);

但事实是,我得到的唯一结果是图像交叉 (IE) 损坏或在 Firefox 中什么都没有。

如果有任何建议,我将不胜感激

提前致谢

最佳答案

readfile()

之前使用php的ob_clean()函数

关于php - 带有 readfile 和 file_get_contents 的损坏图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5877138/

相关文章:

php - php 中超过 4095 个字符的长 URL

php - Codeigniter 类 cron 不起作用

php - mysqli_real_escape_string创建SQL语法错误

php - 无循环按键对多维数组的值求和

php - 如何将这些设置添加到我在 docker 中的 php.ini

javascript - PHP 脚本未在服务器 shell 上显示正确的数据

css - 如何使用css对齐xslt中的文本和图像

python - 给定 4 个点,如何从 pytorch/torchvision 中的图像裁剪四边形?

PHP:如何检查图像文件是否存在?

php - 从 CURL 请求和 file_get_contents 收到的无效 cookie