markthien Posted March 9, 2009 Share Posted March 9, 2009 Hi guys, I need to enable user to upload only text file to my server for processing. How can I detect if the file uploaded is a real text file and not other file like virus file. i guess user can rename a virus file to a text file. thanks & regards, Mark Quote Link to comment https://forums.phpfreaks.com/topic/148593-how-to-detect-if-text-file-is-uploaded/ Share on other sites More sharing options...
WolfRage Posted March 9, 2009 Share Posted March 9, 2009 Really your best bet is to make sure that you append all files with .txt as soon as they are uploaded. Then the file can not be activated, and make sure that users can not remotely call or access the file. Quote Link to comment https://forums.phpfreaks.com/topic/148593-how-to-detect-if-text-file-is-uploaded/#findComment-780308 Share on other sites More sharing options...
JonnoTheDev Posted March 9, 2009 Share Posted March 9, 2009 How can a virus be in a text file? How would an attacker get it to run when it is you that decides where the file is uploaded to. If the text file is to contain certain data then you can read it to verify the contents. Simply checking the file extension will suffice (.txt) and that is as far as I would go. Quote Link to comment https://forums.phpfreaks.com/topic/148593-how-to-detect-if-text-file-is-uploaded/#findComment-780315 Share on other sites More sharing options...
markthien Posted March 9, 2009 Author Share Posted March 9, 2009 how to check if the contain of the file is text instead of other else ? Quote Link to comment https://forums.phpfreaks.com/topic/148593-how-to-detect-if-text-file-is-uploaded/#findComment-780496 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.