Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

php - Broken image with readfile and file_get_contents

I'm trying to use a function in order to get this working:

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

But I can't pass through the function to place the image. I went back a couple of steps and tried only this part of the code:

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

or using this function:

echo file_get_contents($source);

but the fact is that the only thing I get is a broken image cross (IE) or nothing in Firefox.

I would appreciate any suggestions

Thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

use the ob_clean() function of php before the readfile()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...