Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
PHP mime types issue
Trying to make an uploader for a project and set it to only allow .mp3's, so I went with mime types and it still thinks that the uploaded file is never an mp3, even with the correct mime type.
(I know the upload limit is small, there's a reason for that one.)
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$valid=1;
if ($uploaded_size > 35000){
echo "The file is too large.<br />";
$valid=0;
}
if (!($uploaded_type =="audio/mpeg3")){
echo "Only Mp3's are allowed<br />";
$valid=0;
}
if ($valid==0){
Echo "The file was not uploaded";
}
else{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)){
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else{
echo "The file was not uploaded";
}
}```
This is an uploader that I coded from about 3 years:
<?php
$uploaddir = 'upload/';
$uploadfile = $uploaddir.$_FILES['userfile']['name'];
$userfile = $_FILES['userfile']['name'];
$max_upload_size = "5120000";
### Font setup ###
$font = "verdana";
$font_size = "3";
$font_color = "#ff6600";
### Error Messages #######################################################################
# No file to upload
$no_file = "<b><font face=\"$font\" size=\"$font_size\" color=\"$font_color\">Sorry, but you didn't select an image to be uploaded!";
# File is to big
$to_big_file = "<b><font face=\"$font\" size=\"$font_size\" color=\"$font_color\">Sorry, but the image you have select is too big to be uploaded!";
# Not the correct filetype
$not_correct_file = "<b><font face=\"$font\" size=\"$font_size\" color=\"$font_color\">Sorry, but the file you tried to upload is not a valid image!";
# Error to write file to upload directory
$error_write_file = "<b><font face=\"$font\" size=\"$font_size\" color=\"$font_color\">Sorry, but there has been an error processing file! Please try again later!";
# The file is already uploaded!
$already_uploaded = "<b><font face=\"$font\" size=\"$font_size\" color=\"$font_color\">Sorry, the image already Exists on server!";
#########################################################################################
if (!$_FILES['userfile']['name'])
die("$no_file");
if ($_FILES['userfile']['size'] > $max_upload_size)
die("$to_big_file");
if (!in_array($_FILES['userfile']['type'] , array ('audio/mpeg3')))
die("$not_correct_file");
if (file_exists ($uploadfile))
die("$already_uploaded");
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile))
header('Location: http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
else
die("$error_write_file");
?>