Hi Guys,
I've designed an mp3 uploader for my CMS so that the user can change the featured track on their page. It is almost identical to the code that I use for uploading images (which works fine) but it doesn't appear to be working for MP3s.
I've echoed out $_FILES['file']['tmp_name'] and it's empty, so I guess the file hasn't actually been uploaded?
The code for the form is;
<form action="./formsubmit.php" method="post" enctype="multipart/form-data">
<label for="track">Track</label><input type="hidden" name="MAX_FILE_SIZE" value="7340032" /><input type="file" name="track" id="track" class="form_input"/>
<br />
<label> </label><input type="submit" value="Submit" class="button" /></form>
and the code to process the file is;
//Parameters for file checks
$allowed_ext = array('mp3','MP3'); // These are the allowed extensions of the files that are uploaded
$max_size = 7340032; // 2000000 is the same as 2MB
//Error codes set empty
$extensioncheck = "0";
$sizecheck = "0";
$existcheck = "0";
$globalerror = "0";
$successcode = "0";
if ($_FILES['track']['error']==4)
{$existcheck="1";require "file.php";die();}
// Details for image upload and resize
$file_tmp = $_FILES['track']['tmp_name'];
$file_name = $_FILES['track']['name'];
$complete_path_upload = "../mp3/temp.mp3";
//Check File Size Story
if(($_FILES["track"]["size"] > $max_size)){$sizecheck="1";}
// Check Entension
$extension = pathinfo($_FILES['track']['name']);
$extension = $extension[extension];
if(!in_array($extension, $allowed_ext)) {$extensioncheck="1";}
else {$extensioncheck="0";}
// If error codes have been thrown up, refer user back to register page
if ($extensioncheck=="1" || $sizecheck=="1" || $existcheck=="1") {
require "file.php";}
//If all error codes are clear, upload picture
else {
$successcode="1";
move_uploaded_file($file_tmp, $complete_path_upload);
require "file_preview.php";}
It makes it through to the file_preview page, so non of the error codes are being thrown up. I'm at a bit of a loss on this one, unless it is a server setting of some kind?
Thanks as always for taking the time to help and any advice would be gratefully received,