Personally, I do not like to use curl functions that are written to a file. Try instead:
$file_name_array = explode('/', $filename); $file_name_array_r = array_reverse($file_name_array); $save_to = 'system/cache/remote/'.$file_name_array_r[1].'-'.$file_name_array_r[0]; $ch = curl_init($filename); $fp = fopen($save_to, "wb"); // set URL and other appropriate options $options = array(CURLOPT_HEADER => 0, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_TIMEOUT => 60, CURLOPT_RETURNTRANSFER, true //Return transfer result ); curl_setopt_array($ch, $options); //Get the result of the request and write it into the file $res=curl_exec($ch); curl_close($ch); fwrite($fp,$res); fclose($fp);
But you can use something simpler without curl:
$file_name_array = explode('/', $filename); $file_name_array_r = array_reverse($file_name_array); $save_to = 'system/cache/remote/'.$file_name_array_r[1].'-'.$file_name_array_r[0]; $content=file_get_contents($filename); $fp = fopen($save_to, "wb"); fwrite($fp,$content); fclose($fp);
mck89 source share