PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have php code to upload a file. I want to check the extension of the file being uploaded to only allow word or text documents to be uploaded. I'm using an if statement, but am not quit sure how to do it. The code below if what I have, but doesn't seem to work. If anyone has any input, I would greatly appreciate it!
First off, don't rely on the file name being correct nor the content-type provided to be correct either. Both are supplied by the submitting agent and both are easily faked.
Alarmism aside, your comparison should be made against a string. The current code you have would pit a constants division for the comparison; put quotes around "application/msword" and "text/plain."
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
So does it appear that this code should work then?
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]