atholon Posted January 3, 2008 Share Posted January 3, 2008 Hi, once more. I am trying to make a script that compares file extensions with current allowed ones that are pre-defined in an array. Like $allowedEx = array (".jpg",".gif", ".png") but I am not sure how to match it. The upload script is going to be for many different pages so they will refer to a specific functions...for this reason the allowed extensions will change. How could I loop through the array to check them against the extension of the file? Quote Link to comment https://forums.phpfreaks.com/topic/84340-file-extensions/ Share on other sites More sharing options...
wildteen88 Posted January 3, 2008 Share Posted January 3, 2008 use the in_array function Quote Link to comment https://forums.phpfreaks.com/topic/84340-file-extensions/#findComment-429570 Share on other sites More sharing options...
Daniel0 Posted January 3, 2008 Share Posted January 3, 2008 if(in_array(pathinfo('/path/to/file', PATHINFO_EXTENSION), $extensions)) ? Quote Link to comment https://forums.phpfreaks.com/topic/84340-file-extensions/#findComment-429572 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.