In simple terms you can look at each message like this:
Warning = If user does X then the following negative instance will occur
Error = The user has performed x and now the following negative instance is occurring
Basically a warning is a precursor to the error, the error is alerting the user when something is happening in the present moment.
So in your case, if the user inputs the incorrect file type into your form, you may want to show a warning that says for example 'this file type is invalid and won't be accepted' OR once the user inputs the incorrect file type and hits the submit button, an error will show saying something like 'incorrect file type, please use x type'
This way, using a warning, will educate the user to the fact they need to use the correct file type before hitting submit.