2016-06-30 44 views
-1

即時嘗試獲取文件的內容並將其存儲在我的系統上的一個文件中,該函數工作正常,當我指定的url功能工作正常,但是當提供一個它存儲了一個空的文件,這意味着它沒有得到文件的內容,我已經嘗試了幾十個解決方案,但沒有工作,也有一個在php.net上的解決方案,但它也不工作,這裏是代碼:當指定變量fopen無法正常工作

$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")); 
+0

瓦在「」的位置?他們之間似乎沒有任何東西? – Minzkraut

+1

我認爲OP正在嘗試刪除單詞'Vary:' – samayo

+0

@Minzkraut它從輸入'$ items [13]'' – feeela

回答

0

想通了剛剛修剪的變量和它的工作

$filePath = str_replace("Vary:", "", $items[13]); 
$filePath = trim($filePath);