this is my first time writing code in PHP. I am trying to write a simple function that opens a given file. It works fine with .txt files, but when I try to open a .jpg image, it opens it as a long series of characters. This is the PHP code:
<?php
$new = fopen("note.txt", "r");
echo fread($new, filesize("note.txt"));
fclose($new);
?>
This is the code that works and displays the .txt file. However, when I try to open an image -
<?php
$new = fopen("Salamander.jpg", "r");
echo fread($new, filesize("Salamander.jpg"));
header("Content-Type: image/jpeg");
fclose($new);
?>
-I get a long series of question marks, numbers, letters and other characters (near the beginning is the photograph's EXIF data). I guess I have to specify the file's contents in some other way than the way I've done it, but I don't know how. Any help?
P.S. My server in on the computer I am working on.