這里有人可以幫助我解決我的問題嗎?我有這段代碼可以使用 pdftotext 在 Web 上顯示 pdf 文件的輸出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;}它工作正常,但我正在嘗試上傳多個文件并將所有上傳的文件顯示在網絡上。我找不到任何解決方案。你們能幫幫我嗎?:(PS:對不起,我的英語不是那么好。謝謝你!
1 回答

GCT1015
TA貢獻1827條經驗 獲得超4個贊
您在哪里上傳多個文件。你會得到數組中的文件。
因此,您需要遍歷 tmp 文件
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']);
}
- 1 回答
- 0 關注
- 164 瀏覽
添加回答
舉報
0/150
提交
取消