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
$files = array(); foreach ( $_FILES['files'] as $k => $l ) { foreach ( $l as $i => $v ) { //die( print_r( $_FILES, 1 ) ); if ( ! array_key_exists( $i, $files ) ) $files[$i] = array(); $files[$i][$k] = $v; } } foreach ( $files as $file ) { $upload = new Upload( $file ); $suffix = date( 'Y-m-d' ) . '_'; //$upload->mime_check = true; $upload->file_name_body_pre = $suffix; if ( $upload->uploaded ) { $upload->jpeg_quality = panadol_option( 'media_quality' ); if ( panadol_option( 'media_watermark' ) == 'enabled' ) { /** Create watermark. */ $upload->image_text = panadol_option( 'media_watermark_text' ); $upload->image_text_font = panadol_option( 'media_watermark_text_size' ); $upload->image_text_color = panadol_option( 'media_watermark_text_color' ); $upload->image_text_position = 'BR'; $upload->image_text_padding_x = 5; $upload->image_text_padding_y = 5; } $upload->Process( panadol_option( 'upload_url_path' ) . panadol_media_type( $upload->file_src_mime ) ); /** Create image thumbnail. */ $image_is_allowed = $upload->allowed = array( 'image/*' ); if ( $image_is_allowed ) { $upload->file_name_body_pre = $suffix; $upload->image_resize = true; $upload->image_ratio_crop = true; $upload->image_x = panadol_option( 'thumbnail_size_w' ); $upload->image_y = panadol_option( 'thumbnail_size_h' ); $upload->jpeg_quality = panadol_option( 'thumbnail_quality' ); $upload->file_name_body_add = panadol_option( 'thumbnail_append' ); $upload->Process( panadol_option( 'upload_url_path' ) . panadol_media_type( $upload->file_src_mime ) ); } if ( $upload->processed ) { $database = MEDIA_TBL; mysql_query( "INSERT INTO $database ( media_title, media_filename, media_title_uneditable, media_date, media_extension, media_type ) VALUES ( '$upload->file_dst_name_body', '$upload->file_dst_name', '$upload->file_dst_name_body', NOW(), '$upload->file_dst_name_ext', '$upload->file_src_mime' )" ) or die( panadol_database() ); header( 'Location: ' . panadol_sanitize( panadol_cleanurl( '?load=admin§ion=upload-a-media&save=success' ), 'htmlentity_decode' ) ); exit; } else { header( 'Location: ' . panadol_sanitize( panadol_cleanurl( '?load=admin§ion=upload-a-media&save=error' ), 'htmlentity_decode' ) ); exit; } $upload-> Clean(); } else { header( 'Location: ' . panadol_sanitize( panadol_cleanurl( '?load=admin§ion=upload-a-media&save=error' ), 'htmlentity_decode' ) ); exit; } }
Here's my script.
Thank you for creating this great script.