o codigo é esse
<?php if (isset($_POST['cadastrar'])){ $nome = $_POST['nome']; $email = $_POST['email']; $foto = $_FILES["foto"]["name"]; $fotoTmp = $_FILES["foto"]["tmp_name"]; if($nome == ''){ echo'preencha o campo nome'; }else if($email == ''){ echo 'preencha o campo email'; }else if($foto == ''){ echo'seleciona um foto'; }else{ function geraImg($img, $max_x, $max_y, $imgNome) { //pega o tamanho da imagem ($original_x, $original_y) list($width, $height) = getimagesize($img); $original_x = $width; $original_y = $height; // se a largura for maior que altura acho a porcentagem if($original_x > $original_y) { $porcentagem = (100 * $max_x) / $original_x; } else { $porcentagem = (100 * $max_y) / $original_y; } $tamanho_x = $original_x * ($porcentagem / 100); $tamanho_y = $original_y * ($porcentagem / 100); $image_p = imagecreatetruecolor($tamanho_x, $tamanho_y); $image = imagecreatefromjpeg($img); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $tamanho_x, $tamanho_y, $width, $height); return imagejpeg($image_p, $imgNome, 100); } // Chama a imagem, passando os parâmetros a ela., $foto = md5(uniqid(rand(), true)).".$foto"; geraimg($fotoTmp, 340, 280, "fotos/".$foto); $inserir = mysql_query("INSERT INTO cadastro (nome, email, foto) VALUES ('$nome', '$email', '$foto')"); if($inserir == ''){ echo'erro ao enserir'; }else{ echo'Cadastro Efetuado com Sucesso!'; } } } ?>