I can not upload an image to the database. It gives an error "It is necessary to load an image", that is, it already gives an error in the first condition of the following code:

if (!empty($_FILES['img_user'])) { if (!move_uploaded_file($_FILES['img_user']['tmp_name'], 'img/'.$_FILES['img_user']['name'])){ exit("Не удалось загрузить изображение"); } $img_src = 'img/'.$_FILES['img_user']['name']; } else{ exit("Необходимо загрузить изображение"); } 

The form

 <form class="form-horizontal" method="POST" action="?option=reg"> <div class='form-group' style="margin-left: 0;"> <label class="control-label col-xs-3" for='img_user'>Ваше фото:</label> <div class="col-xs-9"> <input type='file' name='img_user' class='form-control' placeholder="Выберите фотографию" id='img_user'> </div> </div> </form> 

    1 answer 1

    You need to specify the enctype="multipart/form-data" attribute in the form tag:

     <form action="handler.php" enctype="multipart/form-data" method="post"> 

    without it sending files will not happen

    • This does not help, unfortunately - FLWRZ4U