Home >Backend Development >PHP Problem >How to access the download link and save the downloaded file in php

How to access the download link and save the downloaded file in php

王林
王林Original
2019-12-14 10:09:117591browse

How to access the download link and save the downloaded file in php

Description:

#A download link on the Internet. When accessed in the browser, a picture will be downloaded. How to use it here? PHP script, access this link, and then save the downloaded image to the local specified folder?

Note: Use a script to access the link, and then save the file returned by the link. This has nothing to do with the browser.

Online learning video tutorial sharing: php video tutorial

##Picture link: https://clarks .scene7.com/is/image/clarks/download/26085012_A

Code example:

$s = file_get_contents('https://clarks.scene7.com/is/image/clarks/download/26085012_A');
$path = './a.jpeg';  //文件路径和文件名
file_put_contents($path, $s);

Related article tutorial recommendation:

php tutorial

The above is the detailed content of How to access the download link and save the downloaded file in php. For more information, please follow other related articles on the PHP Chinese website!

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