> 4. Decoded file is streamed to user, who saves the file locally. > Jason
Below I've provided a starting point to answer your 4th question anyway. It doesn't have a proper strict style or complete error reporting, but it does work (last I checked) and should get you started. -- ===================== Shaun Fryer ===================== http://sourcery.ca/ ph: 905-529-0591 ===================== #!/usr/bin/perl ################################################################################ To download a file via a GET request http://yourhost.tld/path/to/thisScript.cgi?f=/path/to/fileYouWant ################################################################################ # to restrict which hosts can access this script # enter your full or partial IP address below # or comment it out to allow unrestricted access $remote_ip = '192.168.0.'; ################################################################################ use CGI; $q = new CGI; if ($ENV{REMOTE_ADDR} =~ /^$remote_ip/) { if ($q->param('f')) { $file = $q->param('f'); if (!-e "$file") { print $q->header, $q->start_html, $file." doesn't exist!", $q->end_html; } elsif (!-r "$file") { $me = `whoami`; print $q->header, $q->start_html, $file." isn't readable by ".$me."!", $q->end_html; } else { $size = (stat $file)[7]; $file_name = $file; $file_name =~ s/.*\///; select STDOUT; $| = 1; print "Content-Type: application\/force-download\n", "Content-Disposition: attachment\; filename=$file_name\n", "Content-Length: $size\n", "Content-Description: sfryer\'s file downloader\n\n"; open(OUT,"<$file"); binmode OUT if (-B "$file"); $block_size = (stat OUT)[11]; $block_size = 16384 unless ($block_size); while ($length = sysread OUT, $buffer, $block_size) { unless (defined $length) { next if $! =~ /^Interrupted/; } $written = 0; $offset = 0; while ($length) { $written = syswrite STDOUT, $buffer, $length, $offset; } $len -= $written; $offset += $written; } close(OUT); } } } exit 0; ################################################################################ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>