2016-05-16 51 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'); 
相关问题