Be the first to write a review
FREE! Building A File Upload and Rating Application Support
Following on from his free tutorial on building a Content Management System with Server Behaviours and the Advanced HTML Editor, Matt shows how build a site that allows users to upload their own files, and rate those files. There's also a password-protected moderator's area so that you can be sure that all files can be checked before being made "live".
This free tutorial is suitable for beginners and uses only built-in Dreamweaver server behaviors and the DMXzone Pure ASP/ ASP.NET Upload Extensions! The uploading element is also PHP compatible, but the "rating" system doesn't work with PHP since it has no Command behavior to do the rating with.
Building an Upload / Rating Application
Following on from my last free tutorial on setting up a site that could be easily updated by a novice in HTML without breaking anything, this time I'm going to look at DMXZone's Pure ASP Upload extension. Giving users the opportunity to upload items to your site can make for some very useful applications. The ability to share files (for whatever reason) or add their own content can increase the traffic to your site.
Continuing with our sample Jazz community site, let's consider a file upload utility that allows fans to upload MP3 files of their own group playing and have them rated by fellow users. Allowing uploads of this kind needs to be carefully monitored (we don't want people uploading material they don't own the copyright on). So we'll need an admin tool to monitor and approve uploads, much like we did with the News area previously.
Of course there's no reason why your files have to be MP3s. They can be anything (PDFs, Word Documents, images).
Starting off
I'm going to assume you have the existing site set up from the previous tutorial, since there's a bit of duplication. You'll need the same basic setup, with the addition of the Pure ASP Upload extension (or the Pure PHP Upload extension or Pure ASP.NET Upload, depending on your server.) As with the previous tutorial, this is aimed squarely at people who are new to dynamic pages. As before, I've tried to be generic enough that you can use the example here in your own projects without too much fiddling.
Database Tables
For this tutorial you'll need two database tables, the first of which is called cms_uploads. It has the following features:
Column |
Features |
id |
Primary key, identity, Seed 1, Increment 1 |
title |
Varchar, length 60 |
summary |
Varchar, length 400 |
name |
Varchar, length 120 |
live |
Char, length 1, default 'n' |
rating |
Decimal, Precision 2, scale 1, Default 3.0 |
Id is a unique identifier for each uploaded MP3. The title and summary fields contain information about the song. name contains the complete filename (including directory) for the uploaded MP3. I've set it at a maximum length of 120, but if your directories have long names you may need more space. Live indicates if the file is has been approved by a moderator. Rating is the rating out of 5 for the item in question and is decimal rather than integer so that we can have averages when new people rate a song.
The site also makes use of cms_users as created in the last article. As a reminder, this is the structure:
Column |
Type |
Features |
id |
bigint |
Primary Key, identifier |
cms_user |
vchar(20) |
|
cms_pass |
vchar(20) |
This is used to check if a user is valid when they log into the admin system for the uploading section.
If you don't know how to create tables in SQL Server, take a look at the previous tutorial.
Matt Machell
A man of many talents, Matt has been a web designer, technical editor, and jewellery picker. He is currently on contract for the Birmingham City University, producing pages for research centres.
He has tech-edited a dozen books on web design and development for glasshaus, Apress and Sitepoint.
He likes music with loud guitars and games with obscure rules.
His website can be found at: http://www.eclecticdreams.com
He lives in Birmingham with his girlfriend, Frances, and a horde of spider plants.