One of the most common requests I get from customers is the ability for their clients to upload files through a web page (HTTP) to the server; so I threw together from scratch[All of the script was written from scratch execept the HumanReadableSize function] a secure and robust script for this in about 6 hours which clocks in at about 360 lines. The single file works on just the directory it resides it, so the file can be uploaded to any directory you want it to work on with no extra hassle.
I know there are a lot of large applications out there for managed file uploading through a web interface, but I decided to make this anyway as it is kind of specific in its goals, being relatively lightweight and working on just a single directory at a time. Also since I made it myself, it’s easier to modify and update for specific clients needs, like direct integration into their website design.
Its main features are:
- Sorted file listing within the directory
- Upload files of allowed type (invalid extensions are renamed)
- Delete and rename files
- Create and delete user logins
- Logged in users can change their password
- All features are toggleable in three tiers:
- No user file found (Directory access is currently unrestricted)
- Normal user
- Admin user
- Easy basic configuration through a short variable list at the top of the file. Once it is configured the first time for a website, it is unlikely the configuration would need to be changed when copying (or symbolic linking) the file to other directories.