使用 PHP 将图像文件从外部链接写入文件夹的最佳方法


Best way to write the image file into folder from external link using PHP?

>我需要将10000张图像从外部链接存储到文件夹中。于是,我写了cron进程来执行函数。

In My cron file ,
 $img_file = file_get_contents($value1);
                $file_handler = fopen($file_loc,'w');
                if(fwrite($file_handler,$img_file)== false)
                {
                    echo 'error';
                }
                fclose($file_handler);

它的工作正常只有 50 张图像 .我需要存储1000多张图像。fwrite是不是最好的方法?。请帮助我.

您可能会在此脚本上超时。尝试增加执行时间限制:bool set_time_limit( int $seconds );

http://php.net/manual/en/function.set-time-limit.php