in reply to Stripping parts of paths from directory names
and then say:my $path-info = $ENV{PATH_INFO} my $path = "/home/usrs/rjoseph/images"; $path-info =~ s/^[^/]// # strip of preceeding noise $path-info =~ s#[^/\w\.]//g # strip out any non-word dot chars
So if you're writing back URLs to your web users, you can do:my $file_path = "$path/$path-info"; if ( -s $file_path ) { open(FILE, $file_path) or die ...
where @image_list has your real file names in it. You may want to take a look at CGI.pm file upload freaking me outforeach my $file ( @image_list ) { $file =~ s#$path##; # remove the physical path part my $file_name = $file; $file_name = s/\.\w+$//; # strip off extension print "<a href=\"http://mysite.com/cgi-bin/get-image/$file">Image: $ +file_name</a>"; }
a
|
|---|