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.
The foreach() loops are to be used only if you have multiple upload fields.
In your case, you have only one field my_field. You can instanciate the class directly without looping through the $_FILES array.
If you want multiple upload fields, you need to have several fields in your form, and then you will have to loop through $_FILES as in the FAQ. To have several fields, you would need to have something like this in your form:
In your case, you have only one field my_field. You can instanciate the class directly without looping through the $_FILES array.
If you want multiple upload fields, you need to have several fields in your form, and then you will have to loop through $_FILES as in the FAQ. To have several fields, you would need to have something like this in your form: