Hello, here is the code
<?php// ограничение размера файла$limit_size = 1*1024*1024; // 1 Mb// корректные форматы файлов$valid_format = array("jpeg", "jpg", "gif", "png");// путь до нового файла$path_file = "resource/img/avatars/";// имя нового файла$rand_name = md5(time() . mt_rand(0, 9999));if($_FILES){if($_FILES["avatar"]["size"] > $limit_size){ echo 'Error! Make sure that the picture is not bigger than 1MB.'; }else{ $format = end(explode(".", $_FILES["avatar"]["name"])); if(!in_array($format, $valid_format)){ echo 'Error! Make sure that the picture format (png,jpg,jpeg,png).'; }else{ if(is_uploaded_file($_FILES["avatar"]["tmp_name"])){ echo 'Super! Now you have a new avatar.'; move_uploaded_file($_FILES["avatar"]["tmp_name"], $path_file . $rand_name . ".$format"); mysqli_query($link,"UPDATE `users` SET `avatar`= '/$path_file$rand_name.$format' WHERE id=$server"); }else{ echo 'Error! The error loading.'; } } } } ?>
Can peredelat to the photo shrank when adding
or throw off the old or existing code just to make it ("jpeg", "jpg", "gif", "png")