Hey SP,
I’m trying to write a script that records a list of files in a directory filled with pdfs, exe’s, docs and plethora of other binary files and creates a download link to them. I would like to know if such a function exists that could give me the file type in the same format that $_FILES[‘file’][‘type’] returns on a file upload. For instance when I uploaded an .exe the superglobal $_FILES[‘file’][‘type’] will return to me “application/octet-stream” and various other strings. I would look to use this format and I can’t seem to find a function that can simply check and return this information of a file.
I am expecting something like
$file_type = get_file_type('/var/www/file_dir/afile.exe');
And I would write that into some kind of sql insert loop.
Any tips in the right direction would be helpful.