Only if you have a British Residence Permit (BRP) or a short-term student visa issued by the UK. If you do not have either of these documents, you must apply for a Schengen Visa to visit Spain via a Spanish Consulate in your home country.