R
R
Roman Sokharev2014-02-10 02:22:02
PHP
Roman Sokharev, 2014-02-10 02:22:02

PHP: how to get file from download link?

Conditions . There is an api - it works on GET requests. Returns a file in XML/JSON format and the like (the file is downloaded automatically when you click on the url).
Task . Or open the file in a PHP script instead of downloading (ala file_get_contents or curl - it doesn't matter). Or, if the first option is not possible, then save this file to disk - I will continue to parse the file.
In principle, you can not chew too much - just tell me where to dig. A search in the PHP manual did not lead to success - either I was looking in the wrong place, or I was looking for the wrong thing, or "the skis don't go" - it's been almost a day behind the monitor. Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rowdy Ro, 2014-02-10
@greabock

Basically "file upload" is just a custom HTTP header filename=...
Try
system('wget url -O filename');
file_get_contents(filename);
perhaps the server checks the authorization/referer headers, etc., because of this it does not give the file.

H
Halfi, 2014-02-10
@Halfi

en2.php.net/manual/en/function.curl-exec.php

D
degressor, 2015-01-19
@degressor

And if there is a link, but without a site. Sent, say, via Skype and there is nowhere to insert the download attribute, and right-click? Then you can use the savedirectlink.com/ru microservice

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question