$url = 'https://example.com/image.jpg';
$image = file_get_contents($url);
file_put_contents('image.jpg', $image);
$url = 'https://example.com/image.jpg';
$ch = curl_init($url);
$fp = fopen('image.jpg', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$url = 'https://example.com/image.jpg';
copy($url, 'image.jpg');
注意:在使用這些方法下載圖片時,需要確保服務器具有足夠的權限來保存文件。