var_dump($_FILES);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($_FILES && $_FILES['filename']['error'] == UPLOAD_ERR_OK) {
if (isset($_POST['authorname'] ) && isset($_POST['songname'])) {
if ($_FILES['filename']['size'] >= 10485760) {
$log = "Max file size is 10mb";
} else {
$author_name = $_POST['authorname'];
$song_name = $_POST['songname'];
$songName = $author_name . " - " . $song_name;
$url = str_replace(" ", "", $songName);
move_uploaded_file($_FILES['filename']['tmp_name'], "$url.mp3");
$size = round($_FILES['filename']['size'] / 1024 / 1024, 2);
$hash = hash_file('sha256', "song/$url.mp3");
$song = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."song/";
$cur = str_replace('upload.php', '', $song) . $url;
$query = $db->prepare("INSERT INTO songs (name, authorID, authorName, size, download, hash)
VALUES (:name, '9', :author, :size, :download, :hash)");
$query->execute([':name' => $songName, ':download' => $cur, ':author' => $author_name, ':size' => $size, ':hash' => $hash]);
$log = "Success! ID: <b>". $db->lastInsertId() ."</b>";
}
} else {
$log = "Provide a song name and an author name.";
}
} else {
$log = "Error uploading file.";
}
}
/* футер */
footer {
padding: 30px 80px;
background-color: #212121;
color: #fff;
}
/* контейнер дивов */
.apis {
padding: 0 10px 0 70px;
width: auto;
height: 100rem;
}
/* дивы */
.api {
display: inline-block;
padding: 30px;
background-color: #222222;
color: #ccc;
width: 400px;
height: 170px;
margin: 10px;
border-radius: 10px;
}
/* весь контент на странице не включая header и footer */
.container {
display: flex;
flex-direction: column;
height: 100vh;
}