View Full Version : Image Tag Question

05-04-2009, 09:32 PM
This script is used to display image properties and image picture, I want to hide the empty image box that shows on the page before the form is submitted, any suggestions?? Thanks for any help. Joe

Page url: http://www.portal80.org/Search/A_Image.php

<body bgcolor='#ffffff'>

echo "<center><form name='src' action='' method='post'>
<font color='black'><b>URL:</b></font>

<input type='text' size='55' name='url' value='' />

<input type='submit' name='submit' value='Process It' style='background-color:#000; color: #ffffff;'>
<input type='reset' value='Clear' style='background-color:#000; color: #ffffff;'>

$url = $_REQUEST[url];

$contents = file("$url");
for($i=0; $i<count($contents); $i++)
$string .= $contents[$i];
list($width,$height) = getimagesize($url);
echo '<br /><b>Filename: ' . $url . '</b><hr>';
$filename = "$url";
if (($pos = strrpos($filename, ".")) === FALSE);
else {
$extension = substr($filename, $pos + 1);
echo '<b>Width: '.$width.'<br> ';
echo '<b>Height: '.$height.'<br> ';
echo '<b>Extension: '.$extension.'<br> ';
echo '<b>Filesize: ';
echo strlen($string);
echo '<p><center><img src='.$url.'></center>';

05-04-2009, 10:07 PM
have you tried adding
style="display: none;" to the img tage when you are outputting it in php?

05-04-2009, 10:10 PM
from the top of my head...

last line of php code

echo '<p><center><img src='.$url.'></center>';

change to

if( $contents != "")
echo '<p><center><img src='.$url.'></center>';

hope that works for you!

05-04-2009, 10:17 PM
I tried putting the display none tag in the image tag like this

<img src='.$url.' style="display: none;">

the empty box still shows but disappears when the form is submitted. I thought that would have worked. Thanks

05-04-2009, 10:21 PM
Thanks CalumK,
The "if" statement worked perfectly.
Regards Joe

05-04-2009, 10:56 PM
no problemo!