To begin, create clean HTML templates focusing on semantics, establish a default CSS base that functions well regardless of the chosen theme (including basic element positions, images, and font definitions), and define the default theme in a separate file.
There are two possible approaches:
Allow users to customize the appearance of certain elements and save their preferences in the database.
offers a useful widget for selecting colors for elements. If you want to take it further, such as allowing users to drag and drop element positions on the layout, consider using http://jqueryui.com/ (or scriptaculous or another option) and save their positions to the database via HTTP request when dropped.
Allow users to write their CSS file.
If you opt for the user writing a CSS file approach, consider letting them override specific classes of elements. However, the method depends on your goals and the extent of theming you wish to achieve. Provide more details as needed. Instead of uploading the CSS to the disk, consider placing the CSS in a textarea and saving it to the database.
Regardless of the method chosen, it is beneficial to examine how similar approaches function on or to gain insight on the topic.