如何设置Ajax进度栏并显示pdf提取的信息?

我正在构建一个文件上传器并在我的项目中执行。首先,它上传一个发票PDF文件,上传完成后,我提取所有的pdf文本,做了一系列的查询,以存储一些信息的MySQL。PDF大约是40~70页,所以它需要一些时间来处理,我已经有了上传系统与进度条,现在我想做第二个进度条,并显示pdf提取的信息。有人能给我一个建议吗?谢谢。

There a few ways to approach this.

Ajax polling

You can upload the file and set the job's progress in a database. After the file is uploaded you ajax a page which reads the progress from the database.

Without Ajax polling

You can also do this with streaming ,This article is a great place to start. ajax-based-streaming-without-polling

You can use Ajax polling as mentioned by @anvanza. Or you can twist your logic. First you upload all files. Write a callback in files upload function, which initiated another ajax request, which will do all post upload file processing(extracting data from pdf, adding data to database,etc). While the second request in process, you can show the progressbar. Once the second request completes its processing, you can hide the progressbar on successful response from second ajax request.

Hope this logic will help you.