As you read in the title, it is about obtaining visa in Thailand by Thai immigration.
Many people think that they need to leave Thailand to get a visa in Thai embassy abroad but in fact there are 2 forms called TM.86 and TM.87, maybe not well known.
A- If you entered Thailand as Visa Exempt (30 day permitted stay) you need to use the TM.87 Form also know as "application for visa"
B- If you entered Thailand on a Tourist Visa (60 day permitted stay) you need to use the TM.86 Form also known as "application for change of visa"
You can have a look at this brochure from Immigration ( page 2 - section 4 ) : http://bangkok.immigration.go.th/engbroch.pdf
You can find all the TM forms in the immigration website : http://bangkok.immigration.go.th/en/bas … e=download