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
include_once '../classes/class.upload.php'; $time = time(); for($p = 0; $p <= 2; $p++) { $file = 'file'.$p; $k = $p+1; if (!empty($HTTP_POST_FILES['my_field']['name'][$p])) { if (!C_IMG_ERR) { // If Unavailable image upload errors with UIN $dir = date("mY", $time); $slash = "/"; } else $dir = $slash = ""; $fb = date("dHis", $time); $fe = rand(0, 999); $fn = $fb."-".$fe; $handle = new upload($_FILES['my_field']); $this_upload = array(); $dir = date("mY", $time);$slash="/"; $fb=date("dHis",$time);$fe=rand(0,999);$fn =$fb."-".$fe; $intpic = $fn.'.'; $handle->jpeg_quality = 70; $handle->image_watermark = 'watermark.png'; $handle->image_watermark_position = 'B'; $handle->file_new_name_body = $intpic; $handle->Process("uploads/$dir"); if ($handle->uploaded) { if ($handle->processed) { $this_upload['large'] = $handle->file_dst_name; } } $handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_x = 80; $handle->file_new_name_body = $intpic; $handle->Process("uploads/tmb/$dir"); if ($handle->processed) { // store the small image filename $this_upload['small'] = $handle->file_dst_name; $handle->clean(); } // add this set of pictures to the main array $uploaded[] = $this_upload; } if ($uploaded[0]['large'] !='') $d1=$dir.'/'; if ($uploaded[1]['large'] !='') $d2=$dir.'/'; if ($uploaded[2]['large'] !='') $d3=$dir.'/'; $mpic[1]=", pic1='".$d1.$uploaded[0]['large']."'"; $mpic[2]=", pic2='".$d2.$uploaded[1]['large']."'"; $mpic[3]=", pic3='".$d3.$uploaded[2]['large']."'"; }
Input file field has name "my_field[]"