Una semplice Funzione per effettuare un Upload.
PHP:
function upload( $form, $path, array $ext, $size ){
$error = array();
$name = isset( $_FILES[$form]['name'] ) && $_FILES[$form]['name'] != NULL ? $_FILES[$form]['name'] : exit;
$type = isset( $_FILES[$form]['type'] ) && $_FILES[$form]['type'] != NULL ? $_FILES[$form]['type'] : exit;
$file_ext = explode( '.', $name );
$file_ext = strtolower( $file_ext[ count( $file_ext ) - 1 ] );
$tmp = isset( $_FILES[$form]['tmp_name'] ) && $_FILES[$form]['tmp_name'] != NULL ? $_FILES[$form]['tmp_name'] : exit;
$file_size = isset( $_FILES[$form]['size'] ) && $_FILES[$form]['size'] != NULL ? $_FILES[$form]['size'] : exit;
if( in_array( $file_ext, $ext ) === FALSE )
$error[] = 'Errore estensione';
if( $file_size > $size )
$error[] = 'Errore grandezza';
if( empty( $error ) )
/* Prima di effettuare L' Upload bisogna controllare il percorso della Cartella e se il File esiste o meno */
move_uploaded_file( $tmp, $path.'/'.$name );
else
foreach( $error as $error )
echo $error.'<br />';
}