Be the first to write a review
Creating a File Management System with File Genie Support
In this article Patrick will show you how to built a simple File Management System in ASP using File Genie and Pure ASP Upload 3. He will first take you through the steps of creating a basic structure in which the information will be displayed and where the navigation will take place. Next he will walk you through creating a form for adding files.
To end this article Patrick will show you a couple of possibilities for adding extra options to this basic File Management System.
Editing the standard code
All of the building and editing so far was through the user of standard options in the File Genie extension. To get the File Management System working, it now comes down to some hand-coding. Nothing complicated, but Code View is necessary!
First of all, a link will be created for each folder. This link will reload the entire page adding a URL parameter. With this URL parameter the Folder List named Files will be dynamically populated.
- Select the code {Folders.Name} in the Folder List.
- In the Properties Inspector, click on the Browse for File button.
- Select the current page containing the File Management System.
- Click on the button Parameters.
5. Typ the letter f (for folder) in the Name field.
6. Click in the Value column next to the text entered.
7. Click on the little thunder button.
8. Select the option Name from the Folders Folder List.
- Click OK.
- The parameter window has now been filled.
- Click OK.
- Click OK to close the Select File window.
Every time the name of a folder is clicked the page reloads and the URL parameter changes, depending on the folder name.
Next, the Folder List named Files will be edited so that it reads the URL parameter and populates the Folder List.
- Open the Files Folder List from Server Behaviors.
- Edit the path from "media" to "media/"& Request.Querystring ("f").
- Click OK the Close and Save the Folder List.
Now save and upload the file and preview the result in your browser. Click on a folder in the Folder List to have the content of that folder shown in the File List.
Note: The usage of the
folder names as an URL parameter could cause a security flaw. Through changing
the content of the parameter to ../, all the files in the root folder will be
shown!
Creating a Quick-Add form
As for now the File Management System can only show and delete files from selected folders. To simply and quickly add a file to a folder, a Quick-Add form will be created.
Note: The Pure Upload extension is needed to be able to upload files to a folder.
- First create some space after the main table.
- Enter a Form by choosing Insert, Form, Form.
- Inside the form, insert a File field, a Button and a Hidden field.
- Name the Hidden field FolderName and name the File field File.
- Set the value of the Hidden Field to get the URL parameter by first choosing the +-button from the Bindings panel..
- Click on Request Variable.
- Select Request.Querystring in the Type field.
- Enter f in the Name field.
- Click OK.
- Select the Hidden Field and in Properties click on the thunder-button nest to the Value Field.
- Select Querystring.f from the Dynamic Data window.
- Click OK.
- The correct code has now been added into the Value Field.
- Open Pure ASP Upload 3 under Server Behaviors, DMX Zone.
- Make sure you select the correct form. If you followed this tutorial, there should be only one form on the page. Since the form name was not changed, it should be set to form1.
- Set Conflict Handling to Make Unique.
- Select the main folder in the Upload Folder field. This will be edited manually after confirming this window.
- If wanted, activate a Progress Bar on the Progress tab.
- Click OK.
The standard code for the Upload behaviour has now been added. This code now needs to be changed to make sure that the chosen file is uploaded to the selected folder.
- Open Pure ASP Upload 3 from Server Behaviors.
- Edit the Upload Folder so that it reads "media/" &UploadFormRequest("FolderName").
- Click OK.
By editing the Pure Upload behavior, the file that is going to be uploaded will be placed in the folder that was selected. The value for that folder was loaded in the Hidden Field. This field is used to put the folder name behind the name of the main folder.
The completed basic File Management System could now look like this:
Try switching between folders in the Folder List and see that the File List is updated to display the content of the selected folders.
Browse for a file to add and click Submit. The file will be added to the selected folder.
Click the Delete Link to remove a file from the selected folder.
Patrick Julicher
Patrick started developing websites at the age of 25, only using HTML and building simple websites. Through the years his passion for designing and developing grew, and his career moved in that direction in the year 2004, when he decided to try and get a job in ICT and Web Development.
He got this chance at WE ICT, based in Nijmegen, The Netherlands. For the first couple of years he combined network management for customers with creating database-driven websites in ASP. Since 2008 his main work is on the developing part.
While ASP is still his favorite language, he's slowly trying to dive into ASP.NET and discover all of the possibilities.