The most important thing is to be sure to HTML-escape the filenames, as well as also URI-escape the part used as a URL.
This was triggered in the thread upward from Re: directory list.
use CGI qw(a); use HTML::Entities qw(encode_entities); use URI::Escape qw(uri_escape); my $URL_PATH = "http://my.server.com/path/to/pictures"; my $REAL_PATH = "/home/web/htdocs/path/to/pictures"; ... [print the normal CGI stuff up here]... opendir DIR, $REAL_PATH; my @images = sort grep /\.(png|gif|jpe?g)$/ readdir DIR; closedir DIR; print join ", ", map a({href => encode_entities(uri_escape("$URL_PATH/$_"))}, encode_entities($_)), @images;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Show a clickable link list of images from a CGI script
by jmac (Initiate) on Sep 20, 2000 at 20:07 UTC |