Checking for adequate file support

Published by admin on

File Support
You would expect all web hosts to support the basic file types that are essential to the running of the most basic web site, after all, if a server doesn’t know how to deal with a HTML file and the images associated with it then it makes you wonder just how old it is! However, you cannot upload a file to a server and just expect it to work first time. Not all servers know what to do with different files, and may even mistakenly identify some of the more common file types if not set up correctly.

Problems may become apparent when you want to use any sort of files other than your typical HTML, JPEG and GIFs. Even something as simple as a Cascading Style Sheet can cause problems because the extension associated with it (.css) is confused for the lesser common mime type of Corel Slide Show.

File Extensions
How your server deals with various extensions will depend on the software it is running. On Windows systems, extensions are mapped to the application they are intended for, a file with an .pl extension is opened with the Perl Interpreter which then outputs the page dependant on the contents of the file. On a *nix system, the same .pl extension is not important, you would have to explicitly give the path to Perl in the first line of the script for the server to be able to know what program it should use to run the file.

When a server doesn’t know how to deal with a file it will do one of two things, try to open it as a plain text file, or try to download it. These default behaviors are usually undesirable, particularly if you want the file to be sent “as is” for your browser and it’s plug-ins to deal with. It also poses a possible security threat should anyone want to download a file (for example, one of your scripts) and see the paths and sometimes unencrypted passwords stored in them.

It is a good idea to test how your server deals with various file types before you go uploading anything with potentially sensitive content or source code. If the file types you want your server to support are not supported in the way that you would like, then it could simply be a case that the file extensions are not associated with the correct mime types. Depending on your host and server setup, you may be able to add your own mime types; which would even allow you to create your own file extensions and make people wonder just what sort of scripting language you are using!

Mime Types
It must be stressed that not all hosts will offer you the opportunity to add your own mime types and thus it is a good idea to make sure that the server supports all the file types you will be using.

If your host is running Apache, then you may be able to edit the Apache handlers and have files behave like something else entirely different. It is certainly possible to make an .html file parse server side includes by editing the handlers in this way. However, unless you need to parse all your files for includes, it is probably not worth it as this will cause all .html files to be parsed before sending to the browser, putting unnecessary strain on the server.

Categories: Uncategorized