http://www.perlmonks.org?node_id=937603


in reply to Prompt image save

Hi DreamT,

This works for me:

#!/usr/bin/perl -w use strict; use warnings; use CGI::Carp qw{ fatalsToBrowser }; use IO::File; my $png = "test.png"; my $fh = new IO::File($png) or die "Can't read file '$png' ($!)\n" +; my $nbytes = (-s $png); binmode $fh; my $data; sysread($fh, $data, $nbytes) or die "Failed to read data from '$png' ( +$!)\n"; print "Content-disposition: attachment; filename=$png\n\n"; print $data;

Update:  Removed '...' from .png filename in header.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/