im trying to get the contents of file and storing it in a file on my system, that function is working fine, when i specify the url the function is working fine, but when supply a variable which has url stored in it, it stores an empty file, meaning it failed getting the contents of the file, i have tried dozens of solutions but none is working, there is also a solution on php.net but its also not working, here is the code:
$filePath = str_replace("Vary:", "", $items[13]);
//$encoding = mb_detect_encoding($filePath);
//$filePath = mb_convert_encoding($filePath, "ASCII", $encoding);
//$filePath = str_replace("?", "", $filePath);
//$filePath = addslashes($filePath);
//file_put_contents('path/'.$file_name, fopen("".$target_url."","r"));
file_put_contents('path/'.$file_name, fopen($filePath,"rb"));