smalot / pdfparser

PdfParser, a standalone PHP library, provides various tools to extract data from a PDF file.
GNU Lesser General Public License v3.0
2.41k stars 537 forks source link

Warning: file_get_contents(ficheiros/C:\xampp\tmp\phpA3AF.tmp): Failed to open stream: No such file or directory in C:\xampp\htdocs\teste_php\vendor\smalot\pdfparser\src\Smalot\PdfParser\Parser.php on line 79 #713

Closed ItsTheChiva closed 6 months ago

ItsTheChiva commented 6 months ago

Description: The error in the title appears wen i choose the pdf and wen i go to the directory i dont have the Parse.php

PDF input

Expected output & actual output

Code

function extrairPalavrasChaveDoPDF($caminhoTemporarioPDF) { require 'vendor/autoload.php';

$parser = new \Smalot\PdfParser\Parser();

$pdf_path = 'ficheiros/' . $caminhoTemporarioPDF;
$pdf = $parser->parseFile($pdf_path);

$text = $pdf->getText();

return $text;

}

if (isset($_FILES['ficheiro'])) { $ficheiros = $_FILES['ficheiro']; $tudo_certo = true; foreach ($ficheiros['name'] as $index => $nome_ficheiro) { $erro = $ficheiros['error'][$index]; $tamanho = $ficheiros['size'][$index]; $tmp_name = $ficheiros["tmp_name"][$index];

    $deu_certo = enviarArquivo($erro, $tamanho, $nome_ficheiro, $tmp_name);

    if ($deu_certo) {

        $palavras_chave = extrairPalavrasChaveDoPDF($tmp_name); 

        echo "<div id='caminhoPDF' data-caminho='$tmp_name'></div>";
    } else {
        $tudo_certo = false;
    }
}
if ($tudo_certo) {
    echo "<p>Todos os Ficheiros foram enviados</p>";
} else {
    echo "<p>Falha ao enviar os Ficheiros</p>";
}

}

k00ni commented 6 months ago

The path to your PDF file is broken: ficheiros/C:\xampp\tmp\phpA3AF.tmp. Please check $caminhoTemporarioPDF and $pdf_path. I assume it must be

$pdf_path = $caminhoTemporarioPDF;

Its not a problem with PDFParser.

ItsTheChiva commented 6 months ago

ok im gonna try again but if dont work i dont know how im gonna read a pdf file

k00ni commented 6 months ago

Please have a look here: https://github.com/smalot/pdfparser/blob/master/doc/Usage.md