in reply to Re: Showing Word document in browser
in thread Showing Word document in browser

Thank's but I think I didn't tell it right. Let say there is a Word document /docs/word/wordfile.doc but I don't like that visitors can see this path. So I make a Perlscript showdoc.pl?wordfile.doc What does that Perl script had to do. Now I hope I said it in a good way Greeting Ernst
Greetings, Ernst Verster

Replies are listed 'Best First'.
Re^3: Showing Word document in browser
by blazar (Canon) on Jan 12, 2006 at 13:08 UTC

    It seems to me that Celada's reply fully answers your question: the only difference here is that now you want pass the name of the file to download as a parameter, whereas he hardcoded it. You only have to modify his code accordingly, obviously adding the necessary checks as needed.

    Since you're using user input to return something from your local file system, I recommend you read some relevant document related to security issues. You may check the Tutorials section or Ovid's course.

      Thanks for the quick answer but ..... I got this error message: Thu Jan 12 12:55:41 2006 error client 82.168.213.19 malformed header from script. Bad header=\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1: /www/cust/y/3/3/5/33515/cgi-bin/testword.pl The script is the hardcoded version and called testword.pl Maybe you can again think about me and my Perl problem.
      Greetings, Ernst Verster

        Well, I have not much experience with CGI programming. But if you tried his code as is then it's obvious it won't work. It's meant to be only a snippet. In particular you'll notice that there's a $regel variable that is supposed to be a full (relative or absolute) path to your document, but if you didn't set it explicitly, then it will be undefined. Sorry if I'm pointing out something obvious - if not then you should really read some introductory text about Perl first, and then some CGI tutorial as already advised. I may be wrong but I'm getting the impression that you're just copying and pasting code from somewhere else without really understanding it.