Help Needed for Web Based Directory Browser

Help Needed for Web Based Directory Browser

am 23.07.2006 03:31:10 von fuzor_silverbolt

I'm currently working on a simple directory browser written in perl. It
works great on the "home" location but once I click on a link to goto
another directory it will not create hyperlinks to travel to another
directory. I tried this on both winXP/IIS and FreeBSD/Apache2. Any
ideas why this is happening would be appreciated.

#!/usr/bin/perl

use CGI;

$thisurl="dirtest.cgi";

$cgiquery = new CGI();

$choosedirectory=$cgiquery->param('choosedirectory');

print $cgiquery->header();


# Evaluate and Initialize PERL library Cwd
eval "use Cwd;";
if ($@) {&error("Cwd could not be located.");}


#Find the abs path to the current working dir.
use Cwd 'abs_path';
$abs_path = abs_path();

if (!$choosedirectory){
$dirtouse=$abs_path;
}else{
$dirtouse=$choosedirectory;
}

chdir $dirtouse;
opendir MYDIR, "$dirtouse";
@contents = readdir MYDIR;
closedir MYDIR;

print "Directory Lister\n";

print "Current abspath: $abs_path , Current choosedirectory:
$choosedirectory , dirtouse: $dirtouse";

print "

";

Re: Help Needed for Web Based Directory Browser

am 23.07.2006 11:44:50 von Joe Smith

fuzor_silverbolt@hotmail.com wrote:
> I'm currently working on a simple directory browser written in perl. It
> works great on the "home" location but once I click on a link to goto
> another directory it will not create hyperlinks to travel to another
> directory.

Without reading your code, I've got a good idea on what you're doing wrong.

> chdir $dirtouse;
> opendir MYDIR, "$dirtouse";

Yep, that should be
opendir MYDIR, '.';

-Joe

P.S. Don't forget to check for errors in chdir(), opendir(), etc.