in reply to Re^2: opening a file for printing
in thread opening a file for printing

You can try to guess the MIME type using File::MimeInfo, but be warned that it's not perfect and may make mistakes.

use strict; use File::MimeInfo; # ...get $location from DB.... my $mtype = mimetype($location); open my $fh, $location or die "Could not open $location: $!"; print "Content-type: $mtype\n\n"; print while <$fh>;

Replies are listed 'Best First'.
Re^4: opening a file for printing
by sulfericacid (Deacon) on Feb 16, 2005 at 19:06 UTC
    I did install File::MimeInfo (was a tricky thing to install, might I add. lol) and it does half-sorta work.

    I have a test image and a test pdf file in the DB just to see if they load.

    The image loads perfectly. It loads as script.pl?download=8 and when you right click it, you can't see the original source and you can't view the page source. AWESOME!!

    However, when loading the PDF file it doesn't work at all. It says:

    File Download... Filename: accessfiles.pl File type: Adobe Acrobat Control for ActiveX From: domain
    I can't download it because it's a .pl file but it won't load either. Any suggestions?


    "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

    sulfericacid
      Make sure you're sending the right header. Try spitting it to STDERR and looking in the erorr log after you make your request. It should be "Application/pdf". If not, you'll need something smarter than File::MimeInfo.

      It also could be that your browser is improperly configured to deal with PDFs.