The following is the code to search a file and display it.
The code is not working with
pdf files when I try to open the file from a
Windows machine.
The code works when I open it from a
Linux machine.
The file is present in /tmp folder in Linux.
The error message which I get is -->
There was an error opening this document. The file is damaged and could not be repaired.
The error message comes only when I access the file from a Windows machine.
Please tell me why ?
sub searchFile {
my $query = shift;
my $filename = $query->param('filename');
my $conid = $query->param('conid');
my $datetime = $query->param('datetime');
my $oldfile=$filename;
my ($date,$time) = split(/ /,$datetime);
$filename="/tmp/$conid$date$time$filename";
$filename =~ s/[:-]//g;
print $query->header(-type=> "application/octet-stream",-attachmen
+t=>"$oldfile");
open(NEWFILE,"<$filename") or die "Couldn't open file '$filename':
+ $!";
binmode(NEWFILE);
binmode STDOUT;
print <NEWFILE>;
close(NEWFILE);
}
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.