jiexi
jiexi

Reputation: 3029

PHP readfile for force downloading files and images

I want to send files through php using readfile()

What i've noticed is that readfile forces a download, but what if i want to show an image in the browser and not force a download?

Would readfile still force download even if the file is an image?

If it does, is there a solution so i can use tags with it when the file is an image?

Thanks!

Upvotes: 0

Views: 1265

Answers (1)

pestilence669
pestilence669

Reputation: 5701

You need to set the MIME type with the header() function. There should be info in the comments. Something like:

<?php
header('Content-type: image/png'); 
?>

Upvotes: 3

Related Questions