Incredibly Nooby php image display question
Posted: Wed Jun 24, 2009 8:37 am
ok, I am designing a website, and i felt like playing around with php to see if it would make it easier... and i seem to be having the stupidest of problems. I am currently practicing simple stuff to make sure i understand it before applying it to my (mastly designed) website. and i have hit the wall of not being able to display a picture... i have tried fopen --> fread --> echo/print, and imagecreatejpeg --> imagejpeg and in both cases, im pretty sure it is finding the image and all that, but it returns just a page of gibberish, like the stuff that is displayed if you open an image in notepad.
Code for those that are interested: (this is just a muck around/sandbox thingo that i have hosted to play about with stuff)
for the fopen attempt, it was a straight copy paste of the code for the test.txt one above (which works fine), with changed variable names. the source files are all in the same directory on my hosting.
if any more info is needed, leave us a reply.
Lobby
Code for those that are interested: (this is just a muck around/sandbox thingo that i have hosted to play about with stuff)
Code: Select all
<html>
<body>
<?php
$file=fopen("test.txt","r") or exit("Unable to open file!");
$output=fread($file, filesize("test.txt"));
fclose($file);
echo $output;
$image=imagecreatefromjpeg("image1.jpg");
imagejpeg($image);
?>
</body>
</html>
if any more info is needed, leave us a reply.
Lobby