getImageSize() 无法工作

getImageSize() fails to work

我有下面的代码,我不明白为什么我无法检索图像文件的宽度和高度。

 <?php

 $myImage = 'http://www.example.com/storage/james.JPG';


 $imageSize = getimagesize($myImage); // 'line 6'

 $imageWidth = $imageSize[0];
 $imageHeight = $imageSize[1];

 echo 'width: '.$imageWidth.'<br />';  // returns blank
 echo 'height'.$imageHeight.'<br />'; // returns blank


 ?>
 <img src="http://www.example.com/storage/james.JPG"> // image is disaplyed.

我不断收到以下错误:

 getimagesize(thanh.jpg): failed to open stream: No such file or directory in     /home/lifescieco/public_html/newboston_image.php on line 6

很难猜测问题的实际根源,因为您的信息有限。但是,这里有一些您可以执行的检查:

  • 路径是否正确?
  • 文件在操作范围内是否可供 PHP 用户访问?
  • 文件名是否正确?另请记住,某些操作系统区分大小写。
  • 如果文件位于远程计算机上:allow_url_fopen set to 1 (on)? In Windows versions prior to PHP 4.3.0, also take in mind that many functions (including GD and image functions) do not support remote file access. See allow_url_fopen 了解更多信息。