Hi,
This is a very known problem with lot of solutions in many forums but none of them works for me.
A simple code to load a jpeg image as follows:
<html>
<?php
$im = @imagecreatefromjpeg("/home/public_html/MyPic.jpg");
header ("Content-Type: image/jpeg");
imagejpeg($im, NULL, 75);
imagedestroy($im);
?>
<head>
<title>
My First PHP Page
</title>
</head>
<body>
<FORM><INPUT TYPE="button" VALUE="Back"> </FORM>
</body>
</html>
The error message is as follows:
Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/test.php:2) in /home/public_html/test.php on line 4
I have tried with the possible options below:
1. adding ob_start() and ob_flush() at the beginning and end
2. Saving in a notepad with ANSI encoding
3. Removing white-spaces/new-lines before/after php-tags/start-end-of-files/header()
None of them works.
But if I remove the <html> tag (Line:1) at the end of PHP code i.e. after ?> and before <head> then the error goes off and the image is rendered on the screen but all the following html code for title and button in <form> is not having any effect.
I am wondering why the <html> is not recognized and how to design user interaction with clickable buttons at the client-end to perform some image editing operations at the server-end.
Thanks!