This example shows how to create a simple file library. It demonstrates batching and sorting. You can click on the column names to sort the files. If you click twice on a column then the files are sorted in reverse order. If you upload more than eight files, then the results will be split up over more than one page. This is called batching.
The files are located in the Files folder. The getFiles script returns a sorted list of files. The getLink and getSize scripts do small formatting tasks to build hyperlinks and format file sizes. The batching is done in the index_html template. The template also makes use of the test function to assign different CSS classes to elements depending on conditions. This is how the sorted column name is bolded and alternate table rows are made gray.
|example.html||text/html||206 bytes||Apr 17, 2008 2:39 pm|
|example.txt||text/plain||29 bytes||Apr 17, 2008 2:39 pm|
You can add a file to the library by uploading it from your local computer. The addFile script accepts the file upload and creates a new file object in the Files folder. It then returns this page with a confirmation message. For demonstration purposes, only 10 files of no larger than 2Kbytes may be uploaded.
Adding files is protected by the "Add Documents, Images and Files" permission. If you want anonymous users to upload files, you could visit the "Security" tab of the addFile script, and give it the "Manager" proxy role.