Loading...
Обучение/Помощь новичкам | Не загружает/сохраняет файл
Вот код (php):
php
   <?php      require_once "../core/config.php";      if($_SERVER['REQUEST_METHOD'] == "POST" and $account == true and $_FILES == true){         $max_size = 5242880;         $type_file = [".png", ".jpg", ".jpeg"];         if($_FILES["userfile"]["size"] >= $max_size){             header("Location: /account#err-size-file");             exit;         }         if(array_key_exists($_FILES['userfile']['type'], $type_file)){             header("Location: /account#err-type-file");             exit;         }         $uploaddir = "/static/img/uploads/";         $uploadfile = $uploaddir . basename($_FILES["userfile"]["name"]);         move_uploaded_file($_FILES["userfile"]["tmp_name"], $uploadfile);         header("Location: /account#upload-success");         exit;     }else{         header("Location: /account#err");         exit;     }   
Проверял через var_dump(); файл есть, но не в временную папку не загружает и не в uploads, что не так? html код:
html
   <form name="upload" method="POST" action="/api/image/upload" enctype="multipart/form-data">         <label for="new-avatar" onclick="uploadAvatar()" name="userfile" class="blue-button" style="text-align: center;width: 200px;margin-top: 5px;">Обновить фотографию</label>         <input id="new-avatar" type="file" name="userfile" style="display: none;" accept=".png, .jpg, .jpeg">         <input type="submit" value="Обновить" class="blue-button" style="display: none;margin-top: 5px;width: 200px;text-align: center;">         </form>   
тем кому интересно что за js-jq функция uploadAvatar():
javascript
   function uploadAvatar(){     let input = document.querySelector("input[id=new-avatar]");     input.addEventListener("change", (event) => {         $("input[type=submit]").show();         $("label[for=new-avatar]").hide();     }); }   


Изображение

------
76502__20210324_193930.png (41.8 Kb)
Скачиваний: 118
потому что ты Иринка Гг
EagleX , .ыы.
Онлайн: 5
Время:
Gen. 0.0747
(c) Bym.Guru 2010-2026