This common problem is a symptom of several mental illnesses, but is also needs a section of the website for itself. Some articles are shown below - you could start with the 'Overview' article.
-- If you are struggling with self harm, the organisation selfharm.co.uk can help. Check out their website for more, including on-line support.
-- ‘Why do I harm myself?’ is a seminar on this website looking at what self harm is: definition, causes, consequences and approaches to change.