Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w $n = $ENV{'QUERY_STRING'}; @l = split(/=/, $n); $file = $l[1]; if ($file) { undef $/; open (F, "secure/1/$file") or die "Cannot Open File $file\n$!\n"; binmode (F); $f = <F>; close (F); print "Content-Type: application/mpg \n"; print "Content-Disposition: filename=$file\n\n"; print "$f"; } else { print "Content-Type: text/html\n\n"; print "Unknown file\n"; }
as you can see, it's messy, and I want to switch it to use CGI.pm, my question is; the file type isn't always application/mpg so how do I know the type of a file I've read? or is there a common header to send for all binary file types. It's working like that, but I want to make sure it doesn't crash
I won't use this code either, I'll write my own from scratch, but I just need to know the file type thing.
thanx for your help monks out there.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to read content-type from a file?
by Cubes (Pilgrim) on Jul 23, 2001 at 18:14 UTC | |
|
Re: how to read content-type from a file?
by wine (Scribe) on Jul 23, 2001 at 16:05 UTC | |
|
Re: how to read content-type from a file?
by miyagawa (Chaplain) on Jul 23, 2001 at 20:07 UTC |