這邊利用 perl 來實作第二種作法,若你的伺服器是 apache, 檔名要存成 nph- 開頭:
#!/usr/bin/perl
# 若 www server 是 apache,檔名要設定成 nph- 開頭
use File::Find;
use CGI qw/:push -nph/;
# turn off io buffering
$|=1;
my $Pictures = "/home/wade/Pictures";
my $sleep = 2;
print multipart_init(-boundary=>'--magicalboundarystring');
find (\&wanted, $Pictures);
sub wanted
{
my $f = $File::Find::name;
next unless $f =~ /\.jpe?g$/i;
if (open FILE, "$f") {
print multipart_start(-type=>"image/jpeg");
while () { print; }
close FILE;
}
else {
print multipart_start(-type=>"text/plain");
print "File: $f";
}
print multipart_end;
sleep $sleep;
}
exit 0;
0 意見:
張貼留言