1

I have to copy JPG from an external server, such as Facebook, to my server.

What is the best way to do so? I though maybe with fread/fopen etc. but I don't know if it is the best way.

2

2 Answers 2

3

You can use URLs with most filesystem functions (like copy).

$url = "http://cdn.sstatic.net/stackoverflow/img/sprites.png"; $target = "/tmp/stackoverflow.png"; copy($url, $target); 

Do note that you need to have the php.ini setting allow_url_fopen enabled.

Sign up to request clarification or add additional context in comments.

Comments

1
 $url = 'http://facebook.com/image.jpg'; $img = '/my/folder/image.jpg'; file_put_contents($img, file_get_contents($url)); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.