file does not begin with '%PDF-' - Error when searching pdfs on FireFox browser

Discussion in 'Perl Misc' started by lvb, Aug 2, 2006.

  1. lvb

    lvb Guest

    Hello all:

    I have monthly PDFs that I store in a directory and display the 2
    latest ones, the rest user can search them by date (mm-yyyy). Now I
    have 2 questions:

    First, which one is a better solution, store in a directory or in a
    database and retrieve? It just started so we only have a few PDFs now.
    What happens if latter we add more and more PDFs?

    Second, and it's the problem, the PDFs are just fine, I can open them
    directly on any browser. However when I search & open it, it throws an
    error " file does not begin with '%PDF-' " on Firefox and on some IE
    browser (my laptop's IE gives the same error.). I've done some
    research, Adobe gives solution
    http://www.adobe.com/support/techdocs/319294.html
    But it doesn't satisfy me. Does anyone know what happens here? Could
    it be my script's problem? Please see the script below:

    if (defined $ins{newsletter_text}) {

    my $letter = "$ins{newsletter_text}.pdf";

    $path_dir = "/www/html/newsletter/";
    opendir(DIRhandle, $path_dir) || die("Cannot open directory");
    @thefiles= readdir(DIRhandle);
    closedir(DIRhandle);

    foreach $file (sort @thefiles) {

    unless ( ($file eq ".") || ($file eq "..") ) {
    if ($file eq $ins{newsletter_text}) {
    print "location:/newsletter/$ins{newsletter_text}\n\n";
    last;
    }
    elsif ($file =~ /\Q$ins{newsletter_text}\E/i) {
    if ($ins{newsletter_text} =~ m/^\d\d-\d\d\d\d$/) {
    print "location:/newsletter/$letter\n\n";
    } else {
    print "location:/cgi-bin/outdoor.cgi?pg=gov&err=1\n\n";
    }
    }
    }
    }

    Also I realized that when I open the PDF from a link, in the Address
    Bar, it shows the path something like '/gl/newsletter/06-2006.pdf'
    but when I open it from the search form, it show the path somethink
    like '/cgi-bin/gl/newsletter.cgi'

    newsletter.cgi proccess the search and redirect to the PDF. Could it
    be that Firefox considers it as a cgi file?

    Any ideas, please?

    Thanks much in advance.
    lvb, Aug 2, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martin Emanuelsson
    Replies:
    7
    Views:
    125
    Hilary Cotter
    Oct 18, 2004
  2. TrailBlazer

    file does not begin with %PDF - BinaryWrite

    TrailBlazer, Feb 27, 2006, in forum: ASP General
    Replies:
    0
    Views:
    241
    TrailBlazer
    Feb 27, 2006
  3. Ricardo Pog
    Replies:
    1
    Views:
    375
    Austin Ziegler
    Mar 26, 2008
  4. Sean Nakasone
    Replies:
    1
    Views:
    323
    Farrel Lifson
    Apr 14, 2008
  5. johkar
    Replies:
    2
    Views:
    145
    johkar
    Nov 2, 2006
Loading...

Share This Page