How can we save an image from a remote web server to my web server using PHP?

<?php
$file_rimg = fopen("http://w3answers /image23.jpg",'rb');
$newfile_name_img = "/tmp/tutorial.file";
$file_wnew = fopen($newfile_name_img,'wb');
while (!feof($file_rimg)) {
$chunk_rd = fread($file_rimg,1024);
fwrite($file_wnew,$chunk_rd);
}
fclose($file_wnew);
fclose(file_rimg);
?>

www.w3answers.com

what is b stands in codes given??

$file_rimg = fopen("http://w3answers /image23.jpg",'rb');

$file_wnew = fopen($newfile_name_img,'wb');

What is 'b' works in the codes 'wb' or 'rb'??

File operation in php

we can use ftp_connect,ftp_login..ftp built in functions to achive this,the file should have desired permission to access

File Operations in PHP

To read and write to a file ,we should use the fopen() function.fopen takes two arguments,namely the
file name and the access mode

To open a file for reading
fopen($filename,"r");

To write to a file
fopen($filename,"w");

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.