I am creating a file transfer app that will allow users to both upload and download files. I want users to be able to download a file, just by clicking on the link. I know this is so simple, but I must be an idiot. It will not work, but when I copy the html source generated by my script and save it as a html file, it works. I am using the entire path of the file as the link. Also, when I attempt to click on the link nothing happens. Even if I right click and try to open the link in a new window, nothing happens. I am using CGI::App and this is one of my run modes. Here is the snipet:
my $self = shift;
my $q = $self->query();
my $template = $self->load_tmpl("directory_tt.html");
my $dir = $q->param('dir') ? $q->param('dir') : 'c:/projects/p
+ractice/dir';
my $parent_dir = $q->param('parent') ? $q->param('parent') : '
+c:/projects/practice/dir';
opendir(DIR, $dir) or die "cannot open dir $dir";
my (@dir, @files);
while (defined(my $file = readdir(DIR))){
next if $file =~/^\./;
my $full_path = "$dir/$file";
if (-d $full_path){
$file = "<IMG src=/icons/folder.gif> <a h
+ref=readDir.pl?rm=displayFiles&dir=$full_path>$file</a>";
my %row = (
file => $file)
+;
push (@dir, \%row);
}
else{^M
$file = qq|<IMG src=/icons/layout.png>
+ <a href="$full_path">$file</a>|;
my %row = (
file => $file)
+;
push (@files, \%row);
}
}
$template->param(parent=>$dir);
$template->param(dir=>\@dir);
$template->param(files => \@files);
$template->param(dir_name=>$dir);
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.