Reputation: 47
Can someone here can help me on my problem ? I have this code on displaying output of pdf file on web using pdftotext
include ( 'PdfToText-master/PdfToText.phpclass' ) ;
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="pdf_file" multiple="multiple">
<input type="submit" name="SubmitButton"/>
</form>
if(isset($_POST['SubmitButton'])){
$pdf = new PdfToText ($_FILES['pdf_file']['tmp_name']) ;
text = $pdf -> Text;
echo $text;
}
it works fine, But what im trying is to upload multiple files and display it on web all the files uploaded. I can't find any solution. Can you help me guys ? :(
PS: sorry my english is not that good. THank youuu!
Upvotes: 1
Views: 380
Reputation: 318
where you upload multiple file. you will get the files in array.
Therefore, you need to loop over the tmp files
function show_pdf_text($file){
$pdf = new PdfToText ($file) ;
$text = $pdf->Text;
echo $text;
}
if(isset($_POST['SubmitButton'])){
if(is_array($_FILES['pdf_file']['tmp_name'])){
foreach($_FILES['pdf_file']['tmp_name'] as $temp){
show_pdf_text($temp);
}
}else show_pdf_text($_FILES['pdf_file']['tmp_name']);
}
Upvotes: 1