Showing a picture on a page

Hello,

I have a Form which uses CGI and PHP. This Form uploads images to the production server and shows the url of uploaded images on the page (a working example is hier: http://www.eport.at/forms/forms.cgi?form=11).

Well, what I need is that: not the url of the uploaded image which currently this comment generates:
"Uploaded Files:<br/> $uploaded_files_html$ " 
but the image itself to be show on the page. My PHP knowledge is=0,  as HTML it should be: <img src="../../$uploaded_files_html$" >-
how can I write a PHP command for this purpose?
thanks

ShareeceAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Raynard7Connect With a Mentor Commented:
What version of php are you using?

If you run the script

<?php
     $uploaded_files_html = "<a href=\"http://www.eport.at/upload/8977447-84.jpg\">http://www.eport.at/upload/8977447-84.jpg</a>";
     $matches= array();
     $pattern = "/((?<=href=')).*?(?=')/i";
     preg_match_all($pattern,str_replace("\"","'",$uploaded_files_html),$matches);
        echo "<img src=\"{$matches[0]}\">";
?>

Does it work?

It looks as though whatever you are doing it is actually processing your page before php is run over it, this is not normal.

If the above script as an independant page returns a link to the above jpg then it means that the script is working with your version of php - then we need to work out what your cgi script is doing.
0
 
Raynard7Commented:
You should be able to do it exactly the same way. ie
echo "<img src=\"../../$uploaded_files_html$\" >";

What happens when you do this?
0
 
ShareeceAuthor Commented:
I updated the file on the server. It doesn't work. Maybe I have done something wrong? I changed the code like this:
Uploaded Files:
<br>

$uploaded_files_html$<br>
echo "<img src=\"../../$uploaded_files_html$\" >";

A brocken image symbol is been displayed :-(
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Raynard7Commented:
when you did view source how did it display?

the extra $ at the end may be confusing it
0
 
ShareeceAuthor Commented:
0
 
Raynard7Commented:
ok, so what you are parsing is a html href code to your link.

What you will need to do is to split this with a regular expression - and then put it into an img src, will get back to you on that.
0
 
ShareeceAuthor Commented:
I am confused :( Would you give me an example please?
0
 
Raynard7Commented:
Hi,

I was confused what you actually had I thought you just had the location of the image,

what your value is;

<a href="http://www.eport.at/upload/8977447-84.jpg">http://www.eport.at/upload/8977447-84.jpg</a>

meaning that you need to strip the data between

<a href=" and ">

to get the address - and then put this through your img tags.

I'll tell you how to do it but  I'm not the best at using regular expressions (the best way to do this) and am busy at the moment - but will get back to you soon
0
 
Raynard7Commented:
<?
      $matches= array();
      $pattern = "/((?<=href=')).*?(?=')/i";
      preg_match_all($pattern,str_replace("\"","'",$uploaded_files_html$),$matches);
        echo "<img src=\"{$matches[0]}\">";
?>
0
 
ShareeceAuthor Commented:
Hello and thanks, unfortunately it still doesn't work. Maybe I have put the code on the wrong place. The whole code of the page is now like this:

<html>
<head>
<title>Test</title>
</head>
<body>
<form action="$cgiurl$" method=post>
<input type=hidden name="done" value=1>
<input type=hidden name="last_page" value="example_1_pg2">
$form_values$
<center>
<table width=450 cellpadding=4>
<tr><td colspan=2>
Uploaded Files:

$uploaded_files_html$<br>

<?
     $matches= array();
     $pattern = "/((?<=href=')).*?(?=')/i";
     preg_match_all($pattern,str_replace("\"","'",$uploaded_files_html$),$matches);
        echo "<img src=\"{$matches[0]}\">";
?>
</td></tr>
</table>

</form>
</body>
</html>

Thanks
0
 
Raynard7Commented:
what does it return now with the source?
also - why do your values have a $ at the end of them?
0
 
ShareeceAuthor Commented:
It shows exactly this screen as result:
Uploaded Files:
http://www.eport.at/upload/1610565-Test.jpg (this is an Url, which shows the image on a new page)
http://www.eport.at/upload/1610565-Test.jpg (This one not, just a text)

),$matches); echo "(hier a brocken image symbol)"; ?>

Maybe you will want to use the script online and see what happens: http://www.eport.at/forms/forms.cgi?form=11

Why a $ is been used? I don't know, this is a purchased script (form manager). For example if there is a text field with the name of "Address" on the first page, on the secound page stays $Address which retrives the value that has been entered for the Address on the first page.

Maybe some changes in admin.cgi are required. The part of the file admin.cgi that handels the images seems like this:
### Display Image

if($ENV{'QUERY_STRING'} =~ /.gif|.jpg^/gi) {$image = "$ENV{'QUERY_STRING'}"; &Display_Image; exit };
0
 
Raynard7Commented:
Hi,

I'm confused how

$uploaded_files_html$<br> is actually echoing the result of your cgi - it appears that you are not calling php at all in this stage, so I would only expect $uploaded_files_html$ to display at that time.

additionally your system does not appear to support the short tags <? so


<html>
<head>
<title>Test</title>
</head>
<body>
<form action="$cgiurl$" method=post>
<input type=hidden name="done" value=1>
<input type=hidden name="last_page" value="example_1_pg2">
$form_values$
<center>
<table width=450 cellpadding=4>
<tr><td colspan=2>
Uploaded Files:

$uploaded_files_html$<br>

<?php
     $matches= array();
     $pattern = "/((?<=href=')).*?(?=')/i";
     preg_match_all($pattern,str_replace("\"","'",$uploaded_files_html$),$matches);
        echo "<img src=\"{$matches[0]}\">";
?>
</td></tr>
</table>

</form>
</body>
</html>


may work.

how do you normally get the values of your cgi into a variable?
0
 
ShareeceAuthor Commented:
Unfortunately it didn't work again. The Script in already on the webserver. Once I click properties for the brocken image "http://www.eport.at/%22%7B$matches[0]%7D/%22" stays there. also %22 for the name of the image.

As I wrote my PHP knowledge is=0 and this is a purchased script for the contact forms with auto responder, more information is availble hier: http://www.cgi-world.com/form_manager.html. How it gets the values of cgi into a variabel, I have no idea.

Thanks, Sherry
0
All Courses

From novice to tech pro — start learning today.