Hi there I need to download a file from a url and be placed in a folder on my server. Can anyone point me n the direction of what I would need to do with php here. I have tried to search on google but I have little to search on that brings any relevant results. Any pointers here would be great. Thanks a lot
You can use cURL library in php to download a file, like this: function getFile($url){ $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_FRESH_CONNECT,TRUE); //curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5); curl_setopt($ch,CURLOPT_TIMEOUT,180); curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE); curl_setopt($ch,CURLOPT_REFERER,'http://www.google.ch/'); $image=curl_exec($ch); if($image==false){ $m=curl_error(($ch)); die($m); } curl_close($ch); return $image; } Code (markup): But If you have cURL library available then ....