Hi all,
I've modified the browse.php a little, instead of showing the full path with the image you just have top select the directory and then select the image you wish. This is great, except only images on the root will list if you do not enter a directory first. If you enter a directory and select and image a JS error appears and the same happens when you exit the directory and try a root image.
I hope this makes sense :S
I have probably been looking at the code too long and am being, really, really, silly. If you would spare a couple and replace your browse.php with my version or see if you can spot my error I would be forever in your dept.
Take care.
Regards
Byron
PS: Many thanks to Frederico and team for a superb editor.
/*********
Example 1
filename: browse.php
Platform: Win2k
Webserver: IIS5
PHP Version: PHP4.02
*********/
$url = "/intranetdev/upload/";
$base = "/system/webserver/intranetdev/upload/";
$path = $base.$dir."/";
if (!empty($dir))
{
$html_img_lst = "Directory: <b>$dir</b><br><a href=\"javascript:history.go(-1)\"><--Back</a><br>\n";
if ($list = opendir($path))
{
while (false !== ($file = readdir($list)))
{
if (is_file($path.$file))
{
if ($file != "." && $file != "..")
{
$file = $dir."/".$file;
$html_img_lst .= "<a href=\"javascript:getImage('$file');\">$file</a><br>\n";
}
}
}
}
} else {
$html_img_lst = get_dir($base);
}
function get_dir($base)
{
if ($dir = opendir($base))
{
while (false !== ($file = readdir($dir)))
{
if (is_dir($base.$file))
{
if ($file != "." && $file != "..")
{
$dir_list .= "[<a href=\"?dir=$file\">$file</a>]<br>\n";
}
} else {
$dir_list .= "<a href=\"javascript:getImage('$file');\">$file</a><br>\n";
}
}
}
return $dir_list;
}
?>
I've modified the browse.php a little, instead of showing the full path with the image you just have top select the directory and then select the image you wish. This is great, except only images on the root will list if you do not enter a directory first. If you enter a directory and select and image a JS error appears and the same happens when you exit the directory and try a root image.
I hope this makes sense :S
I have probably been looking at the code too long and am being, really, really, silly. If you would spare a couple and replace your browse.php with my version or see if you can spot my error I would be forever in your dept.
Take care.
Regards
Byron
PS: Many thanks to Frederico and team for a superb editor.
/*********
Example 1
filename: browse.php
Platform: Win2k
Webserver: IIS5
PHP Version: PHP4.02
*********/
$url = "/intranetdev/upload/";
$base = "/system/webserver/intranetdev/upload/";
$path = $base.$dir."/";
if (!empty($dir))
{
$html_img_lst = "Directory: <b>$dir</b><br><a href=\"javascript:history.go(-1)\"><--Back</a><br>\n";
if ($list = opendir($path))
{
while (false !== ($file = readdir($list)))
{
if (is_file($path.$file))
{
if ($file != "." && $file != "..")
{
$file = $dir."/".$file;
$html_img_lst .= "<a href=\"javascript:getImage('$file');\">$file</a><br>\n";
}
}
}
}
} else {
$html_img_lst = get_dir($base);
}
function get_dir($base)
{
if ($dir = opendir($base))
{
while (false !== ($file = readdir($dir)))
{
if (is_dir($base.$file))
{
if ($file != "." && $file != "..")
{
$dir_list .= "[<a href=\"?dir=$file\">$file</a>]<br>\n";
}
} else {
$dir_list .= "<a href=\"javascript:getImage('$file');\">$file</a><br>\n";
}
}
}
return $dir_list;
}
?>
<HTML>
<HEAD>
<TITLE>Image Browser</TITLE>
<LINK rel="stylesheet" type="text/css" href="../../css/fck_dialog.css">
<SCRIPT language="javascript">
var sImagesPath = "<?php echo $url; ?>";
var sActiveImage = "" ;
function getImage(imageName)
{
sActiveImage = sImagesPath + imageName ;
imgPreview.src = sActiveImage ;
}
function ok()
{
window.setImage(sActiveImage) ;
window.close() ;
}
</SCRIPT>
</HEAD>
<BODY bottommargin="5" leftmargin="5" topmargin="5" rightmargin="5">
<table width="100%" border="0" height="100%">
<tr>
<td width="25%" height="90%"><DIV class="ImagePreviewLinks"><?php echo $html_img_lst ?></DIV></td>
<td width="75%" height="90%"><DIV class="ImagePreviewArea"><IMG id="imgPreview" border=1"></DIV></td>
</tr>
<tr>
<td width="25%" height="10%"><INPUT style="WIDTH: 80px" type="button" value="OK" onclick="ok();"></td>
<td width="75%" height="10%"><INPUT style="WIDTH: 80px" type="button" value="Cancel" onclick="window.close();"></td>
</tr>
</table>
<BR>
</BODY>
</HTML>