outputing images from a php script,help.
Posted by izrafel (izrafel), 14 September 2005Why cant i output images from a php script when i use
when i run the script directly there is no problem, but if i want to put it on a web page it doesnt want to output the pictures. PLS HELP.
Posted by admin (Graham Ellis), 14 September 2005Without seeing a little more code, I don't know. I guess that you might not have called the header function in your PHP so set the header type, or you may have output extra text / information outside the <?php to ?> tags.
Suggestions to fix:
a) check the things I suggest above
if that doesn't sort it ...
b) Have a look at our working image example in the solution centre and see if it gives you a clue with anything we've done differently there.
Failing that ....
c) Post up a little more code, and tell us HOW it fails - a little more details about what you actually see.
Posted by izrafel (izrafel), 14 September 2005on 09/14/05 at 21:45:21, Graham Ellis wrote:
here is some more code, and for the error is the normal thing that the browser shows when it cant show the image that should be on its place.
Posted by admin (Graham Ellis), 15 September 2005I notice you're using a relative path to the image, also that you noted in your first post that the script works if you don't bring in this part with an include.
When you include or require a file from a different directory in PHP, all relative paths mentioned stay relative to the paths of the original file brought in; this applies to both server side references and - in you example - images, style sheets, etc that are reference client (browser) side.
In other words, you tell us that your code works with the source in
which places the image in
If you run your script via an include from
then it will be looking for the image in
and (since it's not there) it will fail ...
Solution - place the image on a path from where it can be found now that the rules of how it works are highlighted above.
Posted by izrafel (izrafel), 15 September 2005on 09/15/05 at 05:27:52, Graham Ellis wrote:
10x man you are a life saver. It worked. The problem was realy in the links.
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho