Pure ASP Upload Tutorials
Pure ASP Upload - Upload to Organized Folder
Upload to Organized Folder
Many users have asked me how to use this new feature of Pure ASP Upload 2.07 for organizing the uploaded files in different folders. In this tutorial I will explain how is that is to do.
In sites where many files are going to be uploaded you often need a better way to organize them then just upload all in one and same folder.
Lets take as example an intranet site where you will be uploading photo's of all employees. You want those photo's to be organized in different folders dependend on the employee's department. The folder structure you want is like this:
How to do it
To make the file upload to a organized folder, you need to:
- Start with basic upload page
Start with an upload page where you have Pure ASP Upload on it. If you haven't done it yet, go through the Simple file upload tutorial.
- Extend the upload form with Department selection
field
You can edit now the basic form and add some more form fields to it:
As you can see I've add a Department field. This is a drop dwon list that includes all the departments we have. As values I've selected the same strings as the department names. I will use the name of the department to make the upload folder name.
- Open the Pure ASP Upload dialog
Select the Pure ASP Upload dialog by double clicking it on the Sever behaviors list.
- Enter the variable folder
- Save and done
When you need to use a variable folder, you can enter any expression you want in the Upload Folder field. In my example another form field contains the Departments.
So I need the following upload folder expression:
"Employees/" & UploadFormRequest("Department")
this will create a new directory for every non existed department and will place there the photos of each emplyeed that belongs to that department! Non existent folders will be auto-created so this is really powerful! You only need to setup the security on the main Upload folder, for more info how to do this read the Setting the folder security on your server tutorial.
You might also check the Prefix With Full Path option. This option will store the full path in your database (if you are saving the filename in a database). So it will be easy to retrieve a list of all files later on.
NOTE: Note in normal ASP code we will use Request.Form to get the contents of a form field variable, however when using Pure ASP Upload you should always use UploadFormRequest instead of Request.Form
Save your page and upload it to your server, and you are done! Go to your website and test it - you should be able to upload any file to a dynamic folder.
George Petrov
George Petrov is a renowned software writer and developer whose extensive skills brought numerous extensions, articles and knowledge to the DMXzone- the online community for professional Adobe Dreamweaver users. The most popular for its over high-quality Dreamweaver extensions and templates.
George is also the founder of Wappler.io - the most Advanced Web & App Builder