5.2. File upload - making it easy

The (common) final step after building a Website is to load it from your hard drive onto a server somewhere. Sometimes the local intranet server at work. Other times the server on which you rent space personally. Either way, this can be problematic. To see why consider a site with 5 main areas or directories, each containing many tens or hundreds of files. If each one has a regular structure; a directory with the top level file and directories containing related material within it, your mind can 'wander' round the site using a mental model that is simple and logical. Similarly when you want to upload your files, you know where they should go almost without thinking.

Browsers and html with hyperlinks permit a slightly less organised structure than this. It is possible to have 500 html files, all within the same directory, with many of them totally unrelated; which when viewed using a browser, appear to be cleanly linked, nicely grouped etc. I'll let you decide which is easier to maintain!

A goal I use is to imagine a hacker has gained access to my site and wiped all the files, or corrupted them. I want to be able to use an ftp client, visit the site and erase all files in directory X (and all it's subdirectories) and know exactly where to go on my hard drive to find the replacement files. In order to do this the key element is to reflect the server directory structure (in many parts if you keep many 'sites' on your Website) by a directory structure on your hard drive. Imagine I have 3 main subjects on my Website. These are tea, coffee and cocoa. On the server I would like to see something like

  /
  index.html
  /tea
   index.html
   ...
  /coffee
   index.html
   ...
  /cocoa
   index.html
   ...

If I have this as my target, then I'd like to see three different 'website' directories on my hard drive. They might be anywhere on the disk. They don't need to be connected in any way. They don't need to be in the root directory of a disk. But it would be nice if I could type in a command such as

  >cd c:\files\directory1\dir2\cocoa

From which I can see the xml files which make up the cocoa Website. How you organise files within that directory is a little more down to personal preference, although there is one issue

The next consideration is simple housekeeping. Within any single Website, it seems to me better to have all the files which I'll need to upload to the server in the same place? My personal rule is to always build the xml files into a directory named html. Yes, pretty boring, but then I know that if I cd into that directory, I will see a pattern of files and directories that truly reflects the server content. Then all I need to is delete the html content from the server and reload everything from this point downwards, up to the server to re-create the site..

[Note]Note

This includes, of course, all the Microsoft Word files and Acrobat files that you've linked from your html pages! Oh, and don't forget that picture of aunt Jean that you linked in. This is a source of problems for me. All the extras. Make sure you remember them and organize your files accordingly. See Section 5.3 for a little more discussion on this subject

That concludes the site organisation, now how to get it there! As before this document will continue to use ant as the build tool. It should be noted that at the current time, the file transfer protocol(FTP) task is an extension to the basic installed ant, so it is advisable to follow the advice in the Section 2 and download the Apache Commons Net and add the commons-net-1.4.1.jar jar file to the lib directory wherever you have installed ant.