2016-05-16 48 views
0
$content = file_get_contents($image_url); 

這裏打開流我$image_url是dynamic.Whenever我試圖運行它顯示了一些成功的拼搶數據後錯誤的腳本。在失敗的file_get_contents

file_get_contents(http://photos.harcourts.com.au/V2/000/010/936/617-886-VIC-「CloverPark」4127SunraysiaHighwayLexton.jpg): failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request. 
+0

,即使在瀏覽器不開放這個網址! –

回答

1

您可以使用此代碼

<?php 
 
function file_url($url){ 
 
    $parts = parse_url($url); 
 
    $path_parts = array_map('rawurldecode', explode('/', $parts['path'])); 
 

 
    return 
 
    $parts['scheme'] . '://' . 
 
    $parts['host'] . 
 
    implode('/', array_map('rawurlencode', $path_parts)) 
 
    ; 
 
} 
 
$fine_url = file_url("http://photos.harcourts.com.au/V2/000/010/936/617-886-VIC-「CloverPark」4127SunraysiaHighwayLexton.jpg"); 
 
$r = file_get_contents($fine_url);

php - file_get_contents - Downloading files with spaces in the filename not working

0
  1. 在您的網址找到。哪個是錯誤的請求。
  2. 使用單個qoute '或雙重qoute "file_get_contents函數前後的url使其成爲字符串。

file_get_contents('http://photos.harcourts.com.au/V2/000/010/936/617-886-VIC-「CloverPark」4127SunraysiaHighwayLexton.jpg'); 
相關問題