...

View Full Version : Including an image with GET function



cheechm
06-02-2007, 03:06 PM
Hi,
I am trying to include an image using the get function. Script:


<?php include ('tutors/$_GET["tutor"]'.'jpg'); ?>

The file which the script is in, is in the root (/) and the images are in a directory in the root called "tutors". The webaddress is then something like
www.mydomain.com/?tutor=LS

The image in the "tutors" folder is called LS.jpg.
Thanks

whizard
06-02-2007, 03:29 PM
I don't think you 'include' an image - wherever you want it, just put

<img src="tutors/<?php print $_GET['image']; ?>.jpg" />

HTH
Dan

ddanatzko
06-02-2007, 04:23 PM
take a look at this function:

http://us.php.net/manual/en/function.imagejpeg.php

I haven't tried it yet, but that's because I use HTML to render the image

cheechm
06-02-2007, 04:54 PM
take a look at this function:

http://us.php.net/manual/en/function.imagejpeg.php

I haven't tried it yet, but that's because I use HTML to render the image
How do you do it in html?

whizard
06-02-2007, 04:57 PM
See my above post

Dan

ddanatzko
06-02-2007, 04:57 PM
Check Whizard's post, he's got it for you:


I don't think you 'include' an image - wherever you want it, just put

<img src="tutors/<?php print $_GET['image']; ?>.jpg" />

HTH
Dan

cheechm
06-02-2007, 05:00 PM
I can't seem to get that to work.

whizard
06-02-2007, 05:02 PM
In what way - what kind of problem are you having?

I'm not psychic :D

Also, show us the applicable code... for the same reason

Dan

cheechm
06-02-2007, 05:11 PM
Cancel that. Forgot to clear the cache. Sorry. Thanks ;)

ddanatzko
06-02-2007, 05:11 PM
$_GET is a superglobal array used for containing information passed to the script. Are you referencing an image that was uploaded to the page? If so, you can use the copy() function before referencing the file and then reference the file name and location in the img src="<? echo $file; ?>:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum