PHP Multiple File Upload

Hello All,
I am looking for some suggestion/advice. I am creating a form which will let users upload files. The problem is sometime there could be more than 30 files , this files not sure how big they would be . I have restricted the type of files they can upload though. I was thinking to use drag and drop and create a zip folder and then upload the files.
I would really appreciate any suggestions best way to do this.
Many Thanks,
T

Hi @tejudesai5, you could create a drop zone with Javascript without much trouble, where you could drop multiple files as explained in the following tutorial:

I think the most complex bit lies in the actual upload of the data. I would discard the idea of creating a ZIP because it doesn’t grant much benefit, and although that can be done with Javascript on the client machine it would consume as much memory in the host machine as the size of the files, probably up to 2x, which will most probably deplete the user’s machine off memory and make it unresponsive and ultimately crash.

You could send the data as part of the form with a standard form submission without touching JavaScript (apart from making the file drop area, which is a nice-to-have but not necessary). However with this approach, after the user has submitted the form they will have to wait until all the data is uploaded before they get a response from the server. This means that if the files are big they will sit there waiting looking at the screen without any indication of progress or anything happening, only to eventually have the server respond that the files could not be uploaded because they hit a server restriction on the size of the posted data.

The way to solve this is fun but not easy. It means you would have to do an async upload handled by JavaScript, where you would slice the file in chunks of let’s say 2 megabytes each, and send them sequentially one by one, through AJAX requests, to the server, where they will be stitched back together. With this approach you have the ability to make a progress bar, and you will not hit server POST size restrictions.

Enjoy and best of luck!

1 Like

You are right. I cannot make the up-loader twiddle their thumbs while upload is going on. Thank you for your inputs. Will sure update the solution that i go for

1 Like