Home >Backend Development >PHP Tutorial >The easiest way to download images via url in php.

The easiest way to download images via url in php.

WBOY
WBOYOriginal
2016-07-29 09:02:511582browse
<?php
$url =&#39;http://mmbiz.qpic.cn/mmbiz/PGkxayImcuhpTfGWiagtAY1R8L7C1licueqssxnJSJJntscaUrK6vAiakqo4RXdv2bud2ic3YicVbvIghLFhGc5ByyA/0&#39;;
 file_put_contents(&#39;aaa.jpg&#39;, file_get_contents($url));
?>

If you want to download to the specified /www/uplods path, just replace aaa.jpg with /www/uploads/aaa.jpg

The premise is that the directory is writable, you can use chmod 755 /www/uploads

The above introduces the simplest method in PHP to download images through URL. , including relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn