สำหรับดาวโหลดไฟล์ xml
<?php
$url = 'xxx.xml';
$img = 'xx.xml';
file_put_contents($img, file_get_contents($url));
?>
สำหรับดาวโหลดไฟล์รูปภาพนามสกุล jpg หรืออื่นๆแต่ต้องเปลี่ยนตรงนามสกุลครับ
<?php
$content = file_get_contents('http://image.php');
file_put_contents('pic.jpg', $content);
?>
// อีกรูปแบบครับ
function save_image($inPath,$outPath)
{
//ดาวโหลดไฟล์จากเซอร์ฟเวอร์
$in= fopen($inPath, "rb");
$out= fopen($outPath, "wb");
while ($chunk = fread($in,8192))
{
fwrite($out, $chunk, 8192);
}
fclose($in);
fclose($out);
}
save_image('http://เว็บ/xx.jpg','image.jpg');
ไม่มีความคิดเห็น:
แสดงความคิดเห็น