How to download remote file

materix
Member | 2
+
0
-

Hello :-)

I am new to Nette.

Which Nette library do I use for downloading a remote file (image), and save it to disk?

Thanks.

dakur
Member | 269
+
+2
-

@materix Hi, if you mean downloading an image from remote server, just use standard PHP functions – copy(), file_get_contents() etc. – see StackOverflow for examples. If this is not sufficient for you (e.g. allow_url_fopen is off in your php.ini), you can take advantage of more advanced cURL (see also there).


Nette libraries exist to support primary aim of the framework – helping to organize request->response flow using MVC architecture (easily said: to help you handle requests easily and safely). As downloading files from remote destinations are not needed for this, Nette does not have any library which would help with it. But there are others, e.g. Guzzle, which do, even though they can be too complex for your simple problem – just start with the simplest one (native PHP functions) and go for bigger when it is not enough. 😉

Last edited by dakur (2021-03-24 11:27)

PhilCampbell
Member | 1
+
0
-

Thank you for asking, now I have the answer )

Last edited by PhilCampbell (2021-03-26 08:50)

materix
Member | 2
+
0
-

Thanks for a good reply!