niche Posted August 14, 2009 Share Posted August 14, 2009 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 More sharing options...
justsomeguy Posted August 14, 2009 Share Posted August 14, 2009 <?php echo 'tiger-running-snow.jpg';?> Link to comment Share on other sites More sharing options...
Ingolme Posted August 14, 2009 Share Posted August 14, 2009 I think you actually want the HTML <img> tag for this. Link to comment Share on other sites More sharing options...
niche Posted August 14, 2009 Author Share Posted August 14, 2009 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 More sharing options...
justsomeguy Posted August 14, 2009 Share Posted August 14, 2009 You display images in the browser using an HTML image tag. What code are you using? Link to comment Share on other sites More sharing options...
niche Posted August 14, 2009 Author Share Posted August 14, 2009 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 More sharing options...
justsomeguy Posted August 14, 2009 Share Posted August 14, 2009 You can substitute a variable in any echo statement.echo '<img src="' . $file . '">'; Link to comment Share on other sites More sharing options...
niche Posted August 14, 2009 Author Share Posted August 14, 2009 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 More sharing options...
justsomeguy Posted August 14, 2009 Share Posted August 14, 2009 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 More sharing options...
boen_robot Posted August 14, 2009 Share Posted August 14, 2009 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 More sharing options...
niche Posted August 14, 2009 Author Share Posted August 14, 2009 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 More sharing options...
Ingolme Posted August 14, 2009 Share Posted August 14, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.