Re: opening a client application from a server?

ccc31807 <cartercc@xxxxxxxxx> wrote:

Let's say I produce the following file like

How the file is produced in not relevant, so I snipped it.

If I create a hyperlink on an HTML page, like
<a href="outfile.xml">XML DOC</a>
a user can click the link, and the web server will return outfile.xml
to the browser.

If I give the file an xls extension, on a Windows machine running IE
the file will open in Excel.

Sounds like your server is not configured to know what content
type goes with an extension of .doc.

I just don't understand where I should specify the content type.

In the HTTP headers, specifically in a header named "Content-Type".

If you have a CGI program where you've slurped in the contents of
the Word file into $doc, then this should do it:

print "Content-Type: application/msword\n\n";
print $doc;

If it is a static link like in your example above, then you must
have your server configured to send the correct Content-Type header.

My apache, for instance, uses the /etc/mime.types file
to associate a file extension with a content-type.

grep msword /etc/mime.types
application/msword doc

If the CGI approach above works, yet the link approach does not work,
then you can be pretty sure that the root cause of your problem has to
do with web server configuration.

It most certainly has nothing to do with Perl...

Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Relevant Pages

  • Re: jar file not named .jar and "Applet .. notinited"
    ... The MIME type rather than the extension ought to be the authoritative type of the file. ... For example the web server in my NAS device can use PHP to deliver a jar file but the url has to have a .PHP extension so that a script is executed to deliver the file. ... The only other way to alter the configuration of the server to deliver .jar files requires voiding the warranty. ...
  • Re: Uploading Images via PHP
    ... >>uploading a malicious script? ... The web server might be happy to execute them for you if the uploads are ... generally be based on file extensions, so an extension whitelist may be ...
  • Re: IE opens docx/pptx in winzip instead of word and powrpnt
    ... This is a configuration that has to be set for the web server that ... IE will download it with the .docx extension. ...
  • Re: docx files from internet saving as zip files?
    ... no luck. ... It's most likely a configuration issue at the web server end. ... If you download and get a file with a .zip extension, ...
  • Re: [ANN]: Jim interpreter 0.51
    ... Should be faster than loading a complete set of packages. ... Networking will be one major focus of Jim, now I'm working at the event ... start to write pure-Jim TCP and UDP services like a web server, dns server, and so on. ... Everything will be an extension but of course it is trivial if the ...