Hooked product creation up to database.

This also involves a fix for image uploading.