正規表現を使用して、アップロードされているファイルがinput[type="file"]
MP3 であることを確認します。何か問題が発生しています。テストしているファイルは合格しません。
ご協力いただきありがとうございます!
HTML
<input type="file"/>
JavaScript
var file = $input.find('input[type="file"]'),
val = file.val(),
type = /^([a-zA-Z0-9_-]+)(\.mp3)$/;
submit.attr('disabled', 'disabled').addClass('deac');
if (!val){
modal("The upload can't be empty.", true);
} else if (!type.test(val)){
modal("The song must be in MP3 format.", true);
/***********
*
* Getting caught here- even with a valid .mp3 file that _should_ pass the regex
* in my test case using mamp as a localhost, val = C:\fakepath\1.mp3
*
***********/
} else {
/* Success */
}