The result of this question on Baidu seems to be one and then copied and pasted in various ways
Upload the image to the server
function dlfile($file_url, $save_to)
{
$in= fopen($file_url, "rb");
$out= fopen($save_to, "wb");
while ($chunk = fread($in,8192))
{
fwrite($out, $chunk, 8192);
}
fclose($in);
fclose($out);
}
It can be simpler like this
I just happened to write an article: /a/11...
fopen or file_get_contents are simple, but they do not support many features, such as connection timeout and other operations. In actual operation, the script may block for a long time until the PHP timeout setting is reached. If the concurrency is high, it may even bring down the server. Currently, curl is basically used instead