Does anyone know how the real filetype of an uploaded file can be checked in PHP? I would like to know if it is plain text (including csv).
I know I can request the MIME-type (provided by the browser) with "$_FILES['imported_file']['type']" but this doesn't seem to be quite reliable.
For example, if I upload a textfile with extension ".txt", it says it's "text/plain", and if I change the extension into ".csv" and upload the file again, the file type is "application/octet-stream". There are even some differences between the different browsers.
This would mean, that for example people could upload an executable with the extension renamed to ".csv". Then I don't know if I'm dealing with a real csv file, because both would have the type "application/octet-stream".