Title: Is it possible to search in attached files?
Last modified: August 19, 2016

---

# Is it possible to search in attached files?

 *  Resolved [hixen](https://wordpress.org/support/users/hixen/)
 * (@hixen)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/saveexportaccess-userdata-from-forms/)
 * Like the topic says, is it possible to search in attached files?
 * An example: I upload a filenam.doc file to the site, is it possible to have an
   option that says include search in attached files, and WordPress searches throuh
   the filename.doc and shows it’s findings?
 * If it’s possible, can anyone point my into the right direction.

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Thread Starter [hixen](https://wordpress.org/support/users/hixen/)
 * (@hixen)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/saveexportaccess-userdata-from-forms/#post-1603299)
 * Anyone?
 *  [forunner](https://wordpress.org/support/users/forunner/)
 * (@forunner)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/saveexportaccess-userdata-from-forms/#post-1603303)
 * Bad solution, but I don’t know any other.
    I don’t know if WordPress can do this
   alone, but [php can](http://php.net/manual/en/function.file-get-contents.php)
   you have to put the result of this function into a variable, and use a function
   like [that ](http://www.phpsources.org/scripts154-PHP.htm)(I translate the code
   for you) :
 *     ```
       <?php
       /******************************************************************************/
       /*                                                                            */
       /*                       __        ____                                       */
       /*                 ___  / /  ___  / __/__  __ _____________ ___               */
       /*                / _ \/ _ \/ _ \_\ \/ _ \/ // / __/ __/ -_|_-<               */
       /*               / .__/_//_/ .__/___/\___/\_,_/_/  \__/\__/___/               */
       /*              /_/       /_/                                                 */
       /*                                                                            */
       /*                                                                            */
       /******************************************************************************/
       /*                                                                            */
       /* Titre          : find a character in a string                      */
       /*                                                                            */
       /* URL            : http://www.phpsources.org/scripts154-PHP.htm              */
       /* Auteur         : PHP Sources                                               */
       /* Date édition   : 04 Jan 2006                                               */
       /*                                                                            */
       /******************************************************************************/
   
         $my_string = 'abcefghigkmnlopqrstuvwxyz'; // put your variable containing your .doc instead $my_string
         $find_me  = 'a'; // put the search instead $find_me
         $position = strpos($my_string, $find_me);
   
         // you have to use ===  because == won't display anything
         // because the letter 'a' is in position 0
   
         if ($position === false) {
             echo '',$find_me,' not found in ',$my_string,'';
             } else
             {
             echo '',$find_me,' in in  ',$my_string,'';
             echo 'in position ',$position,'';
             }
   
       ?>
       ```
   
 * if the translated code don’t work, try to use the original – maybe I’ve make 
   a mistake.
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/saveexportaccess-userdata-from-forms/#post-1603308)
 * I think what’s being asked here is to have the search look within the documents
   themselves, that’s not quite so simple.
 * The problem with that is that you’d need to query all the files, read the contents
   of each file and check for the search term (that’s alot of work for a script 
   to do), so basically loop over each file, checking contents as you go (not something
   you can do with a query).
 * [http://php.net/manual/en/function.file-get-contents.php](http://php.net/manual/en/function.file-get-contents.php)
 * I’d not consider such a method to be efficient, especially if you’ve got more
   then a handful (5-10) attachments, the processing required would grow as the 
   amount of attachments does.
 * Maybe an alternative would be to tag attachments?
    [http://wordpress.org/extend/plugins/media-tags/](http://wordpress.org/extend/plugins/media-tags/)
 *  [forunner](https://wordpress.org/support/users/forunner/)
 * (@forunner)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/saveexportaccess-userdata-from-forms/#post-1603309)
 * that’s why I said my solution was ” a bad solution ” :p
 *  [Roy](https://wordpress.org/support/users/gangleri/)
 * (@gangleri)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/saveexportaccess-userdata-from-forms/#post-1603310)
 * The search everything plugin has the option to search attachments.
 *  [forunner](https://wordpress.org/support/users/forunner/)
 * (@forunner)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/saveexportaccess-userdata-from-forms/#post-1603312)
 * I don’t think it’s for the content :p
 * > Search every attachment:
   >  (post type = attachment)
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/saveexportaccess-userdata-from-forms/#post-1603313)
 * > that’s why I said my solution was ” a bad solution ” :p
 * I wasn’t meaning to imply there was a problem with your suggestion(ie. a bad 
   suggestion), simply pointing out that it may not fully address the question asked..
   😉 No harm done.. 🙂
 * > The search everything plugin has the option to search attachments.
 * It won’t search “in” attachments though, such as .doc files (or any other file),
   because (well, put simply) the content of those files is not in the database,
   which is where the search is looking, but good suggestion nonetheless.. 🙂
 *  [forunner](https://wordpress.org/support/users/forunner/)
 * (@forunner)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/saveexportaccess-userdata-from-forms/#post-1603314)
 * > I wasn’t meaning to imply there was a problem with your suggestion
 * There is one 😀
 *  Thread Starter [hixen](https://wordpress.org/support/users/hixen/)
 * (@hixen)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/saveexportaccess-userdata-from-forms/#post-1603373)
 * Thanks alot guys, your input was very helpfull.
 * I will tag my attachments since that seems the best way, and write a short description
   for each file.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Is it possible to search in attached files?’ is closed to new replies.

## Tags

 * [attachment](https://wordpress.org/support/topic-tag/attachment/)
 * [file](https://wordpress.org/support/topic-tag/file/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 4 participants
 * Last reply from: [hixen](https://wordpress.org/support/users/hixen/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/saveexportaccess-userdata-from-forms/#post-1603373)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
