![]() |
Kidnapping files via URLs with cURL :)
Hello there :)
I´m playing around with cURL to learn some new things. Anyway i just wanted to share a simple code snippet i came up with when playing around. Nothing revolutionary but handy. I´t will ofcourse need optimization to fitt your individual needs. But in my case i was looking for a way to "download" image files to my server and store them there as files. And i could not use URL wrapers with the conventional ways because of secrity measures by my webhost. So i thought why not try to use cURL and to my suprise the code worked. And this code is just barebone. You are welcome to leave some tips on improvement on this code. Here goes nothing: PHP Code:
Should one use the BINARY option set to TRUE if your retrieving text files like HTML, PHP, XML and so on ? Use my code improve it, or whatever you like :) Good Luck! /EyeDentify |
Thanks for posting up your code snippet! When simply using cURL to grab a file and save it to the local file system, there is the option to tell cURL to do that rather than making us do it with fwrite; that option is
CURLOPT_FILE.PHP Code:
|
@Salathe
Thx for the feedback. :) i was unsure how to use that OPTION but i had it in my mind. So i went with fwrite. Is there any advantage or disadvantage with the either alternatives ? cheers :) have a nice weekend. |
| All times are GMT. The time now is 06:14 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0