Apart from whatever header trickery you had to make to force IE to do what you want there are three more problems with the code!
First, you did not binmode() neither STDOUT nor NEWFILE. While this might possibly work well under a Unix it will definitely break under Windows and may well break under Unixes too with some system and perl settings. By default files are opened in "text" mode, which may mean conversions of line end characters, conversions to or from utf8 and so forth. If you are working with binary data, do use binmode(FILEHANDLE). Always.
Second, you read the whole file into a list, splitting it on newlines (the file is binary, there is no notion of lines there, the newline characters inside are purely accidental!) and then print all elements of the array. This means that the amount of memory you need it proportional to the size of the file. That's not a good thing. You should read the file in chunks (4KB sounds like a reasonable size to me) and print the chunks.
... binmode(STDOUT); open(NEWFILE,"<", "/tmp/$filename") or report_problem("Can't open the +file: $^E"); binmode(NEWFILE); my $buff; while (sysread(NEWFILE,$buff, 4*1024)) { print $buff; } close(NEWFILE);
Then there's another important problem. Security. Imagine someone sends your script conid=../etc/passwd%00. The filename parameter will be completely unimportant in this case since once the filename is passed to the system functions all the stuff after the \x00 character is ignored. This means that you'll dutifully send the hacker your /tmp/../etc/passwd, that is, your /etc/passwd. Erm ... probably not what you intended, right?
In reply to Re: Opening Excel from CGI Program
by Jenda
in thread Opening Excel from CGI Program
by pankaj_it09
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |