Jump to content

Echoing Jpg


niche
 Share

Recommended Posts

I want to display this jpg on my browser and the jpg is in the same directory, but it doesn't work. <?php echo tiger-running-snow.jpg;?>What should I've written?Thanks.

Link to comment
Share on other sites

Either way may browser wants to download the jpg. I need to display it on my browser.What to you recommend?Thank-you.

Link to comment
Share on other sites

Ive tried:<?phpecho ' tiger-running-snow.jpg';?>and<?phpecho '<img src="tiger-running-snow.jpg">';?> What I really want to do is work up to display a jpf that's defined as a variable. I thought PHP would be how I display the image contents of a variable.I may be going about it wrong.If I defined tiger-running-snow.jpg as $file , how could I display it on my browser?Thanks.

Link to comment
Share on other sites

This is what I tried:<?php $file = 'tiger.jpg';echo '<img src="' . $file . '">';?> Firefox prompts me for a download.I need to duplicate this (which works) except I need to display the jpg as a variable:<html><body><img src="tiger.jpg"</body></html> How do I do that?

Link to comment
Share on other sites

You shouldn't be getting prompted for a download, that doesn't make sense. I mean that's just a regular HTML image tag, it shouldn't be trying to download that.

<?php$file = 'tiger.jpg';?><html><body><img src="<?php echo $file; ?>"></body></html>

Link to comment
Share on other sites

Are you sure PHP is running? If by "doesn't work" you mean that a download box is displayed instead, that may mean that PHP is simply not executed.

Link to comment
Share on other sites

Good point about PHP not running. I'm using WAMPSERVER 2.0 and nothing with PHP in it seems to work. Any suggestions?

Link to comment
Share on other sites

Good point about PHP not running. I'm using WAMPSERVER 2.0 and nothing with PHP in it seems to work. Any suggestions?
Access the file through the http:// protocol instead of the file:// protocol.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...