How to detect the finish with file_put_contents() in php?

前端 未结 3 745
独厮守ぢ
独厮守ぢ 2020-12-17 01:08

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.

Curre

3条回答
  •  天涯浪人
    2020-12-17 01:40

    Retrieve the Content-Length header from the remote location first. You can use get_headers to do that. Like so:

    $headers = get_headers($url, 1);
    echo "To download: " . $headers['Content-Length'] . " bytes.
    ";

提交回复
热议问题