______ qstntxt ___

I searched the net but found nothing to upload a file and converted it to %code% and then search the text inside it for results.

/ p>

Someone knows how this is done so I can leave some links for me to study the case.

    
______ azszpr73152 ___

Converting binary files to %code% will not make a search work, each file has its own format.

For each file type you will have to use a method to extract the data and save it in a %code% , some example:

  • XML use link

    Example:

    %pre%
  • CSV use link

    %pre%
  • XLS will probably have to use a library to facilitate such as link or link

  • These are just a few examples, for each format you implement in your application you will have to use a new script.

    I believe that there is no "magic" solution ready for this, you will have to take what exists and create an application based on it.

    To make the query, let's suppose that you saved all %code% to a folder, so you should do a search similar to this:

    %pre%     
    ______ azszpr73192 ___

    I do not know if I understand your question right, but if you want the list of files listed in a txt file, use the following command:

    %pre%

    I hope I have helped.

    Embrace

        
    ___

    0

    I searched the net but found nothing to upload a file and converted it to txt and then search the text inside it for results.

    / p>

    Someone knows how this is done so I can leave some links for me to study the case.

        
    asked by anonymous 07.07.2015 / 00:33

    2 answers

    2

    Converting binary files to .txt will not make a search work, each file has its own format.

    For each file type you will have to use a method to extract the data and save it in a .txt , some example:

  • XML use link

    Example:

    //Caminho que o seu arquivo xml foi salvo
    $xml = file_get_contents('arquivo.xml');
    $frases = array();
    
    $dom = new DOMDocument;
    $dom->loadXML($xml);
    $books = $dom->getElementsByTagName('*');
    foreach ($books as $book) {
        $frases[] = $book->nodeValue, PHP_EOL;
    }
    
    //Salve o $vetor em um txt, assim:
    file_put_contents('arquivo.xml.txt', implode(' ', $frases));
    
  • CSV use link

    //Caminho que o seu arquivo xml foi salvo
    $handle = fopen ("arquivo.csv", "r");
    $frases = array();
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $frases = array_merge($frases, $data);
    }
    fclose ($handle);
    
    file_put_contents('arquivo.csv.txt', implode(' ', $frases));
    
  • XLS will probably have to use a library to facilitate such as link or link

  • These are just a few examples, for each format you implement in your application you will have to use a new script.

    I believe that there is no "magic" solution ready for this, you will have to take what exists and create an application based on it.

    To make the query, let's suppose that you saved all .txt to a folder, so you should do a search similar to this:

    $consulta = 'Palavra';
    $arquivos = array();
    
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if (is_file($dir . $file)) {
                $data = file_get_contents($dir . $file);
                if (stripos($data, $consulta) !== false) {
                     $arquivos[] = $file;
                }
            }
        }
        closedir($dh);
    }
    
    echo 'A consulta "', $consulta, '" encontrou ', count($arquivos), ': ', implode(', ', $arquivos);
    
        
    07.07.2015 / 01:02
    0

    I do not know if I understand your question right, but if you want the list of files listed in a txt file, use the following command:

    exec( "dir $diretorio /s > $NomeArquivo.txt" );
    

    I hope I have helped.

    Embrace

        
    07.07.2015 / 13:44