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

WBOY
Release: 2016-10-17 09:30:01
Original
1529 people have browsed it

Description:

A download link on the Internet will download a picture when accessed in the browser. How to use a php script to access this link and then save the downloaded picture to a designated local folder?

I tried to use curl and file_get_contents, but failed. Please ask the experts for advice and post a demo to watch and learn

<code>https://clarks.scene7.com/is/image/clarks/download/26085012_A</code>
Copy after login
Copy after login

Reply content:

Description:

A download link on the Internet will download a picture when accessed in the browser. How to use a php script to access this link and then save the downloaded picture to a local designated folder?

I tried to use curl and file_get_contents, but failed. Please ask the experts for advice and post a demo to watch and learn

<code>https://clarks.scene7.com/is/image/clarks/download/26085012_A</code>
Copy after login
Copy after login

PHP needs to enable openssl support to access https sites

Is it a picture? Usually the browser will download it for you.
For example, if you give the resource address to the href attribute of a on the html side, then when you click the link, it will be downloaded directly.

If you don’t use such a mechanism and want to write it yourself, the image can be converted to base64 information and stored locally.

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template