In PHP, i will write (create) the file using file_put_contents($filename, $data);
It is ok, but i want to detect the finish event of process.
Currently, the page is showing loading status.
This is currently the way i can know it is finish or not.
I want to detect with the code.
The file_put_contents() function in PHP is an inbuilt function which is used to write a string to a file. The file_put_contents() function checks for the file in which the user wants to write and if the file doesn't exist, it creates a new file.
The file_get_contents() reads a file into a string. This function is the preferred way to read the contents of a file into a string. It will use memory mapping techniques, if this is supported by the server, to enhance performance.
The file_exists() function checks whether a file or directory exists. Note: The result of this function is cached.
This is a blocking, I/O call, so it finishes when the function call returns. The return value is the number of bytes written (upon success).
It puts everything on hold until it's over
So you could use something like this to determine when it has finished writing the file.
echo "The file's contents are now being written, please wait.";
file_put_contents($filename, $data);
echo "The file's contents have been written.";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With