Yeah, so this is the simplest reusable PHP File Uploader I could come up with.
This is the core of the uploader used by BONOBO. The BONOBO implementation has a couple additional proprietary details that we've decided to strip out of this repo to make it as generic as possible.
Although uploading files is well documented, sometimes is not trivial to setup.
With this reusable implementation, simply drop the entire repo onto a folder. Then browse to that folder, and the uploader launches - as simple as that.
Drop it on a PHP-enabled folder and open index.php. It should work right out of the box.
- Index.php starts off the script and shows the upload form.
- This docuemnt submits to itself, and next time around it checks if there are files
- Although it's currently locked to uploading a single file, the script expects an array of files, so you could upload multiple by simply adding the
multiple
flag to the Input File tag. I just don't have a need for it currently. If you need muitple files, edit the tag like this:
<input type="file" class="custom-file-input" id="file" multiple>
I've been able to succesfuly upload files up to around 250mb. However, there seems to be an Apache restriction regarding how long a script can run, so it times out after running for around 10 minutes.
If anyone knows how to solve this, PULL REQUESTS are accepted and encouraged!
- It's specified on the header of
index.php
:$uploadFolder = "files/";
Yes, PLEASE. If you use it and have something to contribute, please send a PULL REQUEST.
Ricardo Alcocer - https://alco.rocks
MIT - alco.mit-license.org