Ask php download file problems
Purpose: Download files from remote links
Problem: Remote link provides a CSV format file download, such as: http://adscendmedia.com/campaigncsv.php, after accessing the link browser prompt download, how to download this file directly to the server via PHP code? (This is a code snippet running in the background, so you can not choose "Save as" way to download), a variety of regular download methods have tried, what is the way?
------Solution--------------------
There are two possible reasons: one is that some sites do not support the file_get_contents,fopen of functions such as crawling. Second, http://adscendmedia.com/campaigncsv.php turned to a new Web site, which is the file to be downloaded.
For the first reason, you can try the curl function, and the Curl series function is better at simulating the browser.
For the second reason, there are two ways to get a new URL. One way is in the browser's download function, in the file download process can be seen. Instead, the header information returned will be output using the Socket series function of PHP.
------Solution--------------------
Add: You can also try the socket series function crawl.
------Solution--------------------
I looked, and the Web site turned to https://adscendmedia.com/campaigncsv.php.
Attention is HTTPS!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.