ThePsion5 Posted August 22, 2006 Share Posted August 22, 2006 Hi,I'm trying to use the file_get_contents() to crawl websites, but i'd also like to screen what kind of files i'd be opening using the 'context' option (to exclude .pdf files, for example). I believe this is possible, but I don't really know how. Any ideas? Link to comment Share on other sites More sharing options...
Little Goat Posted August 22, 2006 Share Posted August 22, 2006 so you store the filename in a variable, explode it by the period and take the last element of the array, and you'll see what the extension is. Link to comment Share on other sites More sharing options...
ThePsion5 Posted August 22, 2006 Author Share Posted August 22, 2006 Hi,I'd also like to screen what kind of files i'd be opening using the 'context' optionAs in, I don't want to exclude files that way specifically, as the logic designed to filter files is located in a different object...What I do want to do is exclude non-text-based files because that is a universal specification. As in, i don't want to say "no .pdf, .wmv, or .avi files" or "only .htm, .php, and .html files" but no non-textual files. Perhaps I could use something with MIME types for this? Link to comment Share on other sites More sharing options...
Little Goat Posted August 22, 2006 Share Posted August 22, 2006 so you want ASCII files only, and no Binary files?the mime_content_type function to the rescue:http://us2.php.net/manual/en/function.mime-content-type.php Link to comment Share on other sites More sharing options...
ThePsion5 Posted August 23, 2006 Author Share Posted August 23, 2006 Sadly, I can't use that functions without enabling it in the PHP.ini file, which is my problem (If I had administrative access i'd just use the PECL extension, lol). I wonder if I should go through the arcane profess of using binary to determine the MIME type? *gulps* Link to comment Share on other sites More sharing options...
Little Goat Posted August 23, 2006 Share Posted August 23, 2006 check out this:http://www.phpclasses.org/browse/package/922.html Link to comment Share on other sites More sharing options...
ThePsion5 Posted August 24, 2006 Author Share Posted August 24, 2006 Ah hah! That's actually exactly what I need! I appreciate you finding that for me. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now