1

I want to create a file by calling a python script inside a PHP script, and download the file while is being created. Is there any way to do it?

Here is what I thought it could be like:

<?php
    set_time_limit( 0 );
        $handle = popen('python python/test.py', 'r');
        echo header("Content-type: plain/text");
        $output = stream_get_contents ($handle);
        echo substr($output, 1);
        pclose($handle);
?>

The problem with this code is that the PHP script waits until the file is entirely created, but I don't want that.

Blackbam
  • 17,496
  • 26
  • 97
  • 150

0 Answers0