PHP

HOW TO CURL DOWNLOAD FILES IN PHP

FILE HANDLER $fh = fopen("FILE", "w");

PHP CURL DOWNLOAD (A)

01

CURL INIT $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "HTTP://SITE.COM/FILE"); curl_setopt($ch, CURLOPT_FILE, $fh);

PHP CURL DOWNLOAD (B)

02

CURL RUN curl_exec($ch); if (curl_errno($ch)) { echo curl_error($ch); } else { echo "OK"; }

CLOSING UP curl_close($ch); fclose($fh);

WE DON'T NEED CURL ACTUALLY. $source = "HTTP://SITE.COM/FILE"; $destination = "FILE"; file_put_contents(   $destination,   file_get_contents($source) );

DOWNLOAD WITHOUT CURL

03