php, getimagesize
In server is many pictures, they pictures have names with space, examples: home 3.png, my new car.jpg. And i need get all images sizes. Why getimagesize() show errors with those images?
Error:
Warning: getimagesize(http://127.0.0.1/img 1.jpg) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found...
If i run picture: http://127.0.0.1/img 1.jpg in browser everything good (so link good).
Full code:
<?php
require_once('simple_html_dom.php');
$string = str_get_html('some text some text <img src = "http://127.0.0.1/img 1.jpg" /> text开发者_JAVA百科 .... ');
foreach($string->find('img') as $e)
$img[] = $e->src;
$img_1 = getimagesize($img[0]);
print_r($img_1);
?>
You should work with files, not urls.
Based on my comment:
Make sure that the server running the php script has actual access to the file. In this case, as you try to get the image from 127.0.0.1, the php server has to be the same server the image is located on.
If you are trying to run this from a remote server, it is of course not working. When you open the path in your browser, you are accessing your local server (on your own computer), but an external server won't be able to access it that way. If it is in your network, use your real IP or host name instead; if it is not in your network either have to make your local server publicially available or simply move the image to somewhere else.
精彩评论