Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File download.... 2

Status
Not open for further replies.

JimJx

Technical User
Joined
Feb 16, 2001
Messages
202
Location
US
Hi all, I have a file download routine that I am working with. It works great except that no all files show up.

For example, if I have a .txt file,k it shows, if I have a .doc file, it does not. Can anyone help me out?

Any suggestions appreciated.
Jim



Code:
print "<form action=\"download.cgi\" method=\"post\" enctype=\"multipart/form-data\">\n";
print "<font color=\"#552500\" size=\"2\">";
print "Please select a file to download.<p />\n";
opendir(MYDIR, $invDir) or die "Cannot open $invDir: $!";
my @dir= grep(-f,readdir(MYDIR));
closedir(MYDIR);

print "<select name=\"file\" size=\"1\">\n";
print "  <option selected value=\"\">Choose one...</option>\n";
foreach my $dirname (sort @dir) {
$temp = "$invDir" . "/$dirname";
$temp =~s|^.*/(.+)\.\w+$|$1|; 
print "<option value=\"$dirname\">$temp<br />\n";
}						
   						
print "</select>\n";
 
An update on this.....

I uploaded a couple more files so I have a total of 4 files in the folder. 3 txt files and 1 doc file. Only 2 of the txt files are showing up.....

Any help greatly appreciated before I get even more gray hair from this.....

Jim
 
instead of:

Code:
my @dir= grep(-f,readdir(MYDIR));

try;

Code:
my @dir= readdir(MYDIR);

and see if all the files show up. If they do, the -f filetest operator is not returning true for all the files in the folder.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Yep, all of the files showed, thank you.

One question though, with the routine that I have, how do I keep the . and .. files from showing?

Thanks,
Jim
 
for $file (@dir)
{
next if $file =~ /^\.\.?$/;
print "$file\n";
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Excellent everyone, thanks!
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top