<?php
include('db.php');
if (isset($_FILES['src_track'])) {
$expensions = array("mp3", "wav");
$src_track = $_FILES['src_track']['name'];
$src_track_size = $_FILES['src_track']['size'];
$src_track_tmp = $_FILES['src_track']['tmp_name'];
$src_track_type = $_FILES['src_track']['type'];
$src_track_ext = strtolower(end(explode('.', $src_track)));
move_uploaded_file($src_tmp, "../tracks/" . $src_track);
}
if (isset($_FILES['cover'])) {
$expensions = array("jpeg", "jpg", "png", "webp", "svg");
$cover = $_FILES['cover']['name'] ? $_FILES['cover']['name'] : NULL;
$cover_size = $_FILES['cover']['size'];
$cover_tmp = $_FILES['cover']['tmp_name'];
$cover_type = $_FILES['cover']['type'];
$cover_ext = strtolower(end(explode('.', $cover)));
move_uploaded_file($cover_tmp, "../img/covers/" . $cover);
}
$name = isset($_REQUEST['name']) ? $_REQUEST['name'] : NULL;
$id_owner = isset($_REQUEST['id_owner']) ? $_REQUEST['id_owner'] : NULL;
$tag1 = isset($_REQUEST['tag1']) ? $_REQUEST['tag1'] : NULL;
$tag2 = isset($_REQUEST['tag2']) ? $_REQUEST['tag2'] : NULL;
$tag3 = isset($_REQUEST['tag3']) ? $_REQUEST['tag3'] : NULL;
$tag4 = isset($_REQUEST['tag4']) ? $_REQUEST['tag4'] : NULL;
$resData = array();
$sql = "INSERT INTO `tracks`(`name`, `src`, `cover`, `id_owner`, `tag1`, `tag2`, `tag3`, `tag4`) VALUES ('$name','$src_track','$cover','$id_owner','$tag1','$tag2','$tag3','$tag4')";
$rs = mysqli_query($db, $sql);
$resData['success'] = $rs;
$resData['message'] = $_FILES['src_track'];
header('Location: /profile.php?id=' . $id_owner);
<form class="popup-setting__form" method="post" action="components/addtrack_action.php" enctype="multipart/form-data">
<input type="hidden" name="id_owner" value="<?= $_SESSION['user']['id'] ?>">
<div class="popup-setting__item name__settings">
<label for="name">Название</label>
<input class="popup-setting__input-text" type="text" name="name" id="name" required>
</div>
<div class="popup-setting__item">
<label for="cover">Обложка трека</label>
<input class="popup-setting__input-file" type="file" name="cover" id="cover" required>
</div>
<div class="popup-setting__item">
<label for="scr_track">Трек</label>
<input class="popup-setting__input-file" type="file" name="src_track" id="src_track" required>
</div>
<div class="popup-setting__item">
<label for="add_tag1">Добавить тег</label>
<input class="popup-setting__input-text" type="text" name="tag1" id="add_tag1">
</div>
<div class="popup-setting__item">
<label for="add_tag2">Добавить тег</label>
<input class="popup-setting__input-text" type="text" name="tag2" id="add_tag2">
</div>
<div class="popup-setting__item">
<label for="add_tag3">Добавить тег</label>
<input class="popup-setting__input-text" type="text" name="tag3" id="add_tag3">
</div>
<div class="popup-setting__item">
<label for="add_tag4">Добавить тег</label>
<input class="popup-setting__input-text" type="text" name="tag4" id="add_tag4">
</div>
<button type="submit" class="popup-setting__save">
Добавить
</button>
</form>
Есть форма, которая получает картинку и аудио файл. С картинкой проблем не возникает, а вот аудио файл не сохраняется на сервере. Путь указан верно, в базу данных данные о имени файла приходят.