doupai8533 2010-03-12 03:50
浏览 55

在字符串中使用&符号的PHP getimagesize会产生错误

I'm using the getimagesize function in PHP, and the path string contains an ampersand, which otherwise is fine. The page gives me errors where getimagesize() is called. Looking at the source code, though, I see the ampersand is being passed through as & rather than just & I presume this is causing errors because PHP doesn't need to convert it to the html tag in order to find the path, right?

Here is the error:

Warning: getimagesize(image.php?name=username&pic=picture) [function.getimagesize]: failed to open stream: No such file or directory

  • 写回答

1条回答 默认 最新

  • doubao6936 2010-03-12 05:29
    关注

    If you want getimagesize to fetch the image from a remote server, by sending an HTTP request and downloading it, you need to use an absolute URL (starting with http://domainname.ext/...)


    For example, this portion of code :

    $url = 'http://static.php.net/www.php.net/images/php.gif?test=glop&blah=huhu';
    $data = getimagesize($url);
    var_dump($data);
    

    Gives me :

    array
      0 => int 120
      1 => int 67
      2 => int 1
      3 => string 'width="120" height="67"' (length=23)
      'bits' => int 7
      'channels' => int 3
      'mime' => string 'image/gif' (length=9)
    


    If you don't want to fetch a remote image, then, you need to specify the path to an image that exists on the same machine than the one where PHP runs.

    And, in your case, I doubt that you have a physical file called 'image.php?name=username&pic=picture'.

    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题