Lost written about Trojan attacks. Suggest googling it as it a worthwhile read.
However, some basic guidelines. Before you save a file i.e. when uploaded you should do all the checks isFile(), isValid, isExecutable() , isDir() etc. This will get you half way.
You should write an adapter so that user never accesses the file directly i.e. the user makes a request to read, view, etc. the code then gets the file and passes it back to the user i.e. not hard coupling from UI to any file, which requires permissions, etc
I also use UUID for directory and file names, not that it would stop a Trojan, but provides a level of obscurity.
The cheapest and easiest way to provide a level of security beyond AV, Web Content Security, Script Parses, etc. Is to create a white and black list files by mime that you allow, which is a challenge when it comes to email.
Then there are server anti-virus solutions and client (Javascript) solutions that will do a binary read to check to see if the file is of mime type, but they are basic. In the end a smart person can get around it I'm sure, but every step is another wall.