Nice suggestion, but it may have some issue when current extension is "jpeg" because it will not match the returning mimetype "jpg" and become " *.jpeg.jpg "(it still works but just looks weird). Another approach is we append the guessedExt only when currentExt is not exist.