in reply to Need help with downloading
#!/usr/bin/perl -w use strict; use File::Type; my $file = $0; print "Pragma: public\n"; # reportedly required print 'Content-Type: ', File::Type->new()->mime_type($file) || 'applic +ation/force-download', "\n"; print "Content-Disposition: attachment;filename=$file\n"; print "Content-Transfer-Encoding: binary\n"; print 'Content-Length: ', -s $file, "\n\n"; open(FILE, "$file"); binmode $_ foreach (*FILE, *STDOUT); print foreach (<FILE>); close(FILE);
Verified to work with Apache on Linux.
UPDATE: Removed unnecessary variables
|
|---|