dopo aver eseguito l'upload e prima dell'inserimento nel db:
codice:
if(isset($_FILES['nome_file_upload'])){
$tmp_name = $_FILES['nome_file_upload']['tmp_name'];
list( $width, $height, $type ) = getimagesize( $tmp_name );
$new_width = 640;
$new_height = $height / $width * $new_width;
if ($type == 1)
$src_img = imagecreatefromgif( $tmp_name );
if ($type == 2)
$src_img = imagecreatefromjpeg( $tmp_name );
elseif ($type == 3)
$src_img = imagecreatefrompng( $tmp_name );
$im = Imagecreatetruecolor( $new_width, $new_height );
imagecopyresampled( $im, $src_img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
ob_start();
imagejpeg( $im );
imagedestroy( $im );
$data = ob_get_clean();
$data = addslashes( $data );
}
p.s.: devi cambiare il valore di $_FILES['nome_file_upload'] col nome del campo upload del tuo form.