Forum Moderators: coopster
I'm trying to include a php file but at the same time pass a variable with the url
include("download.php?file=$file"); The error message I get is "Warning: Failed opening 'download.php?file=' for inclusion"
How do I overcome this? Or is it not possible to do?
have a look
Here [us2.php.net]
Solved that little problem, still not getting the result I want though :(
This is my download.php
<?php
$file = $HTTP_GET_VARS['file'];echo "<img src = \"$file\">";
?>
However I'm not getting an image displayed. I get the image box and the properties has my domain followed by $file rather than the actual file name and path. I checked the address bar and that is showing the right file
$file = $HTTP_GET_VARS['file'];
include 'http://sims2.hazelryan.co.uk/download.php?file=$file'; I echoed the $file before the include and it comes out fine
but when it passes through to download.php it goes wrong
<?php
$file = $HTTP_GET_VARS['file'];echo "<img src = \"$file\">";
?>
I may be missing something here. What is the point of including a file to simply echo a variable? If that's the full contents of download.php, then it's just not worth putting in a separate file.
why not just use this directly in the script:
if ( isset($_GET['file']) ) print '<img src=' . $_GET['file'] . ' />';
If you still wish to include the simple echo script, then you should be able to do so by simply setting the var in the main script. The include will have access to the var, along with any other vars in the main script.
You may want to look again at the link that henry0 gave you in msg# 3.
Are you actually wanting to include all of the file, download.php, within your script, or are you just wanting to create an image tag that reads:
<img src="http://yoursite.uk/download.php?file=value">
If you are just wanting to create a tag, try:
$file = $HTTP_GET_VARS['file'];
$tag = "<img src=\"http://yoursite.uk/download.php?file=$file\">";
echo $tag;