Monday, July 21, 2008

Managing Uploaded Files

In the context of a web site, a file can be addressed either by it's network address as seen by the web servers, either by it's URL as seen by the browsers. These two adresses needs to be available to our application, the first to manage the files internally, the later to serve our users.

These two addressing schemes do not use the same format, and may not share the same paths. A network address and it's related URL might indeed look like :

\\fileserver\share\picture1.jpg
http://www.mysite.com/pictures/picture1.jpg

If we need to keep track of the files uploaded to our website, how should we store their location in our database? We should take care to strip any information relating to a specific addressing scheme, and retain only the file's name.

picture1.jpg

It is our web site's configuration and application logic that should provide for the reconstruction of the original addresses.

No comments: