class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
If you have multiple upload fields, they will have the same name, right?
So assuming that you have three of these upload fields, called my_field[], and that the user enters a file for the first and third field only, $_FILES will be as following:
With this code:
Or there is some better solutions for that?
So assuming that you have three of these upload fields, called my_field[], and that the user enters a file for the first and third field only, $_FILES will be as following:
We need to re-organize the array for the class, with.
So we have now in $files:
So we need to modify our loop so that $files doesn't include the second entry in the array, which is for the non-uploaded file. So the loop becomes:
So now you can feed $files into class.upload.php, for instance doing as following: