Welcome to the tutorials of Pure PHP Upload 2.
In this list of tutorials you will learn how to create a file upload, restrict certain files or sizes of files from being uploaded, upload files and insert them in a database and much more...
In this list of tutorials you will learn how to create a file upload, restrict certain files or sizes of files from being uploaded, upload files and insert them in a database and much more...
Many users have asked me how to use this new feature of Pure PHP Upload 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:
To make the file upload to an organized folder, you need to:
So I need the following upload folder expression:
"Employees/" .$HTTP_POST_VARS['Department']
this will create a new directory for every non existed department and will place there the photos of each employee 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.
Since PHP version 4.1.0 it is also posible to use $_SESSION and $_POST.
DMX 2004 uses $_SESSION and $_POST as a default.
You can read more detailed info about reserved variables online at php.net.
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.
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