It sounds like what you're doing is correct but you'll need to set the MIME type and of course send the data.
I use a system which allows download of all sorts of files, and since I can't be 100% sure of the accuracy of the file extension I do the following
print "Content-Type: application/x-unknown-download_file\nContent-Disp
+osition: attachment\; filename=\"".$fileOBJ->data('filename')."\"\nCo
+ntent-Length: $size\n\n";
I use the line:
Content-Disposition: attachment\;
to force the browser to download the file rather than try to display the file, and the application/x-unknown-download_file is a MIME type I made up (you can make up your own, it's fun) so that the browser doesn't think it knows the file type.
As for the actual output of the data, that's a fairly easy:
open(my $DLFILE, $file);
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
+$blksize,$blocks) = stat($DLFILE);
print "Content-Type: application/x-unknown-download_file\nContent-Disp
+osition: attachment\; filename=\"".$fileOBJ->data('filename')."\"\nCo
+ntent-Length: $size\n\n";
# here's the downloading part, no arrays needed
while ($bytes = read($DLFILE,$buffer,16384)) {
print $buffer;
}
That should do it.
Tosh
|