Hi, my code successfully uploads images to a folder on my server called uploads. I add the Mime type
audio/mp3 and audio/mpeg to my list of allowed filetype uploads. Heres my code that wont upload specifically audio. images work fine, so the database connection and uploading to the server is not a problem.
Are these the correct mime types for a regular mp3 file? i’ve tried all my mp3 files and they all dont work. anyway here it is:
[php]
<?php
session_start();
if($_SESSION["id"] == $userid && isset($_SESSION["login"]))
{
if (isset($_POST["uploadsubmit"]))
{
if ($_FILES["upload"]["name"] == "")
{
$_SESSION["upload"] = "Please choose a file to upload";
$_SESSION["uploadsuccess"] = "";
$_SESSION["uploadsize"] = "";
}
if ($_FILES["upload"]["name"] != "")
{
$_SESSION["upload"] = "";
}
if ($_FILES["upload"]["type"] == "image/gif")
{
$_SESSION["upload"] = "Filetype not supported";
}
if ($_FILES["upload"]["size"] > 1000000)
{
$_SESSION["uploadsize"] = "File size is too big";
$_SESSION["upload"] = "";
$_SESSION["uploadsuccess"] = "";
}
if (empty($_POST["title"]) || strlen($_POST["title"]) > 50)
{
$_SESSION["title"] = "Please enter a title for your uploaded file";
}
if (!empty($_POST["title"]) && strlen($_POST["title"]) < 50)
{
$_SESSION["title"] = "";
}
if (empty($_POST["describe"]) || strlen($_POST["describe"]) < 10 || strlen($_POST["describe"]) > 200)
{
$_SESSION["describe"] = "Please give your uploaded file a description (Must be between 10-200 characters)";
}
if (strlen($_POST["describe"]) > 10 And strlen($_POST["describe"]) < 200)
{
$_SESSION["describe"] = "";
}
if ($_POST["category"] == "SELECT A CATEGORY")
{
$_SESSION["category"] = "Please select the category you wish your uploaded file to feature in";
}
if ($_POST["category"] != "SELECT A CATEGORY")
{
$_SESSION["category"] = "";
}
if ($_FILES["upload"]["name"] != "" && $_FILES["upload"]["size"] < 1000000 && $_SESSION["describe"] == "" && $_SESSION["category"] == "" && $_SESSION["title"] == "" && $_FILES["upload"]["type"] == "image/jpeg" || $_FILES["upload"]["type"] == "image/png" || $_FILES["upload"]["type"] == "image/pjpeg" || $_FILES["upload"]["type"] == "audio/mp3" || $_FILES["upload"]["type"] == "audio/mpeg")
{
$name = $_FILES["upload"]["name"];
$type = $_FILES["upload"]["type"];
$file_name = $_FILES['upload']['name'];
$random_digit = rand(0000,200000);
$new_file_name = $random_digit . $file_name;
$directory = $new_file_name;
$path = "uploads/" . $new_file_name;
if(copy($_FILES['upload']['tmp_name'], $path))
{
require "chapterpdo4.php";
}
}
}
?>
Select a File:
<?php echo $_SESSION["upload"]; echo $_SESSION["uploadsize"]; ?>
<?php echo $_SESSION["uploadsuccess"]; ?>
Title: <?php echo $_SESSION["title"]; ?>
Description:
<?php echo $_SESSION["describe"]; ?>
Category:
SELECT A CATEGORY Singing
Dancing
Modeling
Programming/Development
Art
Acting
Music/Songwriting
Comedy
Rapping
Tricks
<?php echo $_SESSION["category"]; ?>
[/php]