Hello,
I am working on a script that will enable a user to remove files from a fixed directory. I have been able to get the script to list all of the files in a certain $location and allow the the client to check the files that need to be removed, but for some reason it only removes the last "checked" file. Here's what I'm working with:
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$buffer);
foreach $pair (@pairs) {
($name, $value)=split(/=/,$pair);
$value =~ tr/+/ /;
$value=~s/%(..)/pack("c",hex($1))/ge;
$f{$name}=$value;
chomp($f{$name});
}
print "<tr><td bgcolor=#CCCCCC><b> File Removal</b></td></tr></ta
+ble>";
if(($f{'action'} eq "delete")&&(open(FILE,$f{'file'}))){
unlink($f{'file'})||print "<h1>Could Not Delete: ".$f{'file'}."</h
+1>";
}
$dir=$f{'dir'} if $f{'password'} eq $password;
opendir(DIR,$dir);
@files=readdir(DIR);
closedir(DIR);
@files=sort(@files);
print "Directory Content:";
$i=0;
foreach $file(@files){
if((!opendir(TEST,$dir."/".$file))&&($f{'password'} eq $password)&
+&($file ne ".")&&($file ne "..")){
$i++;
print "<input type=checkbox name=file value=\"".$dir."/".$file
+;
if($i==1){
print "\" checked>";
}else{
print "\">";
}
print $file."<BR>\n";
}
}
print "<input type=hidden name=dir value=\"".$location."\">\n";
Any suggestions on how to remove multiples files instead of just one at a time?
Thanks! Lisaw
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.