Why wont my mp3 file upload to the server?

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]

you can try this

[php]

if (move_uploaded_file($_FILES[‘upload’][‘tmp_name’], $path))
[/php]
instead of
[php]
if(copy($_FILES[‘upload’][‘tmp_name’], $path)

[/php]

try that and see what happens

Im not by my server now, but the problem is not with that statement, because the jpeg, png, and pjpeg
file types (images) upload fine to the server and database. Am I using the right audio mime types for mp3?

audio/mpeg
is mp3

So what am I doing wrong?

is your file less then 1000000

also may be you have

|| $_FILES["upload"]["type"] == "audio/mp3" || $_FILES["upload"]["type"] == "audio/mpeg"

maybe take the

$_FILES["upload"]["type"] == "audio/mp3" ||
out just a suggestion

I tried that. ive tried taking out the audio/mp3 or the audio/mpeg. i dont get why the server will upload the image types i specified, and will not allow gifs like i specified, and then once i add 1 audio mime type, it totally
flips out by doing absolutely nothing. no database path, no server upload. only with the other specified filetypes. not audio/mpeg. i really dont know why. anything i may be missing? thanks :frowning:

Ive seen something like this before on another forum , the guy said the issue was the built in load time error in php , apparently the default on his server was 20 secs and the mp3s were taking longer than that due to the size, im sure one of the experts can expand on this . Hope this helps.

ahh in your php.ini look to see if your size is too small

upload limit and post limit

specifiicaly how do i edit the .ini file to raise the limit of the post and upload sizes?

do you have a host or your own webserver

host should have a editable php.ini in your control panel

if you have a web server its in the /etc/php or /etc/php5 or /etc/php4 folder

let me know how it goes

I understand that the control panel of a hosted server would have a feature for that, while a localhost server would require you to find the .ini file in the php/ file. The problem is, what codes do I edit to adjust the upload and post limits? Thanks

post_max_size = 8M is default
and
upload_max_filesize = 2M is deafualt

these you need to change

What does “M” stand for? megabytes? megabits?

megabytes

Now i tried to adjust the upload_max_filesize = 2M to upload_max_filesize = 5M

and tried to save the file and it said Access denied. How do i get permission to edit the php.ini file?

is this a host or your personal machine

host they should have a special .ini for you to edit

or ask them

And for the size of this?: $_FILES[“upload”][“size”] > 1000000

Does this mean 1000000 Megabyes, Kilobyes, or what?

I think those are bytes

you can try adding these to the top of your php file see if they will change the size for you

[php]ini_set(‘post_max_size’, 100000);
ini_set(‘upload_max_filesize’, 100000);[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service