I've got a perl script that I can hit like:
server.com/get.pl?&file=file.kml
And have it hand my web browser the file as if I downloaded a link (not plaster the file on the screen).
Except, when I try to do this with compressed files like Zip files or Kmz (google Earth zip files), the file gets plastered on my screen just like I opened up a text file.
I think that's the problem, that I'm treating a file like a text file when it's a zip and has different encodings perhaps. But, I don't know what those encodings are for being able to open the file and shoot it out to the user.
The output I'm actually trying for is a google earth kmz file, but it's the same as a zip file, just called kmz instead of zip. If I can get a zip to work, the kmz will work too.
Code below.. Pretty well stumped. Any help appreciated.
Thanks!
sub kmzLoader(){
my ($KmlLoaderFile)=@_;
open (DEST, "<$KmlLoaderFile") || warn "kmlLoader:: Can't load fil
+e";
my @dataBuff = <DEST>;
close DEST;
$zipData = join ("\r",@dataBuff);
}
sub outKmz(){
print <<"OUTZIP";
Content-Type: application/vnd.google-earth.kmz
Content-Disposition: attachment; filename="$fileName"
$zipData
OUTZIP
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.