如何在php保存完文件后通知用户


How to inform the user when php is done saving the file?

经过这篇文章中的建议,我终于让我的代码发挥了作用。

$myFile = "data.txt";
$fh = fopen($myFile, 'w');
$x = $result . "'r'n";
fwrite($fh, $x);
fclose($fh);

PHP是连续的。如果你告诉它保存到一个文件中,然后回显后记,它就会做到这一点。它将完成保存到文件,然后回显后记。但我必须问一下——你能在提交函数中执行另一个单独的PHP文件吗?如果是这样的话,那么在保存文件的后台过程完成之前,上面的伪代码很可能会被回声掉。。。

经过这篇文章中的建议,我终于让我的代码发挥了作用。

$myFile = "data.txt";
$fh = fopen($myFile, 'w');
$x = $result . "'r'n";
fwrite($fh, $x);
echo "Done Saving!";
fclose($fh);