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.
more info about the class
for($p = 0; $p <= 2; $p++) { $file = 'file'.$p; $k = $p+1; if (!empty($HTTP_POST_FILES['my_field']['name'][$p])) { ...
With this code:
Or there is some better solutions for that?