L
ll
I'm currently working with a cgi script which can upload, view, or
delete files in a given directory. The delete section is rather
cumbersome, in that the user has to type in the file name and password
and then hit the delete button.
I've created an html form in the view section that puts checkboxes
next to each file listed. Here's the code I have (below). I'm
getting an error that says that the 'post' command isn't recognized.
Thanks for any help,
Louis
------------------------------------------------
sub listfilenames {
&check_url_referer;
if ($in{'pwd'} ne $superpwd) {
&error_password;
}
if (!$in{'filedirname'}) {
&error_no_upload_directory;
}
$list_dir = "$parent_dir$in{'filedirname'}";
if (opendir(DIR,"$list_dir") == 1) {
@files = readdir(DIR);
closedir(DIR);
}
else {
&error_cannot_open_dir;
}
&set_content_type;
print "<html><body><center><font size=+1 color=
\"FF0000\"><b>Listing of Filenames</b></font></center><p>\n";
print "<b>The following filenames are found in directory
\"$in{'filedirname'}\":<br>\n";
print "<form method=\"post\" action=\"uploader_ee.cgi\">";
print "<table border=\"1\">\n";
$count = 0;
foreach $fitem (@files) {
$fitem_pathname = "$list_dir" . "/" . "$fitem";
if (-e $fitem_pathname) {
if (-d $fitem_pathname) {next;}
$count++;
print "<tr><td><input type=\"checkbox\" VALUE=$fitem></
input></td><td> $fitem </td><td>- <a href=
\"$parent_url$in{'filedirname'}\/$fitem\" target=\"_blank\">View this
file</a><br></td>\n";
}
}
if ($count == 0) {
print " Sorry, nothing found!!<br>
\n";
}
print "</table>\n";
print "<input type=\"submit\" value=\"Delete File\">\n";
print "</form>\n";
print "</b><p>\n";
print "</html>\n";
&listfilenames_ok;
}
delete files in a given directory. The delete section is rather
cumbersome, in that the user has to type in the file name and password
and then hit the delete button.
I've created an html form in the view section that puts checkboxes
next to each file listed. Here's the code I have (below). I'm
getting an error that says that the 'post' command isn't recognized.
Thanks for any help,
Louis
------------------------------------------------
sub listfilenames {
&check_url_referer;
if ($in{'pwd'} ne $superpwd) {
&error_password;
}
if (!$in{'filedirname'}) {
&error_no_upload_directory;
}
$list_dir = "$parent_dir$in{'filedirname'}";
if (opendir(DIR,"$list_dir") == 1) {
@files = readdir(DIR);
closedir(DIR);
}
else {
&error_cannot_open_dir;
}
&set_content_type;
print "<html><body><center><font size=+1 color=
\"FF0000\"><b>Listing of Filenames</b></font></center><p>\n";
print "<b>The following filenames are found in directory
\"$in{'filedirname'}\":<br>\n";
print "<form method=\"post\" action=\"uploader_ee.cgi\">";
print "<table border=\"1\">\n";
$count = 0;
foreach $fitem (@files) {
$fitem_pathname = "$list_dir" . "/" . "$fitem";
if (-e $fitem_pathname) {
if (-d $fitem_pathname) {next;}
$count++;
print "<tr><td><input type=\"checkbox\" VALUE=$fitem></
input></td><td> $fitem </td><td>- <a href=
\"$parent_url$in{'filedirname'}\/$fitem\" target=\"_blank\">View this
file</a><br></td>\n";
}
}
if ($count == 0) {
print " Sorry, nothing found!!<br>
\n";
}
print "</table>\n";
print "<input type=\"submit\" value=\"Delete File\">\n";
print "</form>\n";
print "</b><p>\n";
print "</html>\n";
&listfilenames_ok;
}