BlogPHP Raw CurlThe regular PHP file functions sometimes are too slow and inadequate. In such cases you can use the raw "curl" command, which is faster and more adaptable. 1. Get the Headers of Remote File using cURL
2. Download Remote File using cURLOn an average server a 120MB file will take about 20secs. Impressive. function rawCurlDownload($sourceUrl, $targetPath, $options = []) { $headers = isset($options['headers']) ? '--header "' . $options['headers'] . '"' : ''; $cmd = 'curl -X GET ' . $headers . ' --output "' . $targetPath . '" -O ' . $sourceUrl . ''; exec($cmd, $out); if (file_exists($targetPath) == false) { return false; } return true; } Loading blog_post_recommendations...
|