--- Lupo <[EMAIL PROTECTED]> wrote: > (Sorry for my English...) > > Can I request an image-path with Perl? > > ....<img src=myfile.pl>...
Yes. There are two ways to deal with this. One is to have your perl script redirect the browser to the location of the image: #!/usr/bin/perl -wT print "Location: /path/to/image\n\n"; The other is to dynamically generate the image. Let's say that this is the HTML: <img src="myfile.pl?image=3"> Note that the attribute value is quoted! It's not important in this example, but it's easy to have problems with that in the future. We can use this in our code (untested): #!/usr/bin/perl -wT use strict; use CGI qw/:standard/; use constant IMAGE_DIR => '../images/'; my @images = qw/ default.gif one.gif two.gif three.gif four.gif /; my $image = param( 'image' ) || 0; # use default if no param ( $image ) = ( $image =~ /^([0-4])$/ ) || 0; # untaint or assign default $image = IMAGE_DIR . $images[$image]; open IMAGE, "< $image" or die "Cannot open $image for reading: $!"; binmode IMAGE_FILE; # In case we're on Windows print header( 'image/gif' ); print <IMAGE>; close IMAGE; The untainting will seem weird if you're not used to it. Read 'perldoc perlsec' for more information on this. Hope that helps. Cheers, Curtis "Ovid" Poe ===== Senior Programmer Onsite! Technology (http://www.onsitetech.com/) "Ovid" on http://www.perlmonks.org/ __________________________________________________ Do You Yahoo!? Check out Yahoo! Shopping and Yahoo! Auctions for all of your unique holiday gifts! Buy at http://shopping.yahoo.com or bid at http://auctions.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]