execute PHP script and get an update of process

63 Views Asked by At

I need to write a script in PHP that read a list of XML and convert them in a text file

I will add a button in my page that triggers

exec("xml2csv.php");

since i can have a lot of them i would like to give user feedback on process update, it can be a text feedback

kind of like javascript image upload with % update

i'm not sure is possible and how to proceed

1

There are 1 best solutions below

2
On BEST ANSWER

Provided you know the number of lines or bytes of XML you must parse, have your PHP script write to a file on the server the number of bytes (or lines) it has completed writing periodically throughout the scripts execution using file_put_contents().

On the client side, using AJAX, poll the server for the contents of this file and display this result to the user every x seconds. Using jQuery's $.POST would be good for this.