Replaced the file mime type variable with the output from an accurate function
Added a check to ensure that a file is actually an uploaded file and not a trick to point at a local file
Improved the invalid package check so that it not just checks the mime type but also ensure that mime type matches the repo
Added a check in case no files are uploaded * Moved the target directory creation behind the no errors check to prevent the folder being created needlessly and never tidied up