如何判断远程文件是否为图像 [英] how can I tell if a remote file is an image
问题描述
我写了一个链接别名脚本,允许用户在他们的网页上重写网址
。脚本的关键如下:
if(getimagesize($ redirect_to)== 0)
header(" Location:$ redirect_to") ;
其他
包含($ redirect_to);
哪个使用getimagesize()来判断是否指定了链接在
$ redirect_to指向一个图像(即img src),在这种情况下它应该
包括页面中的图像,或者链接指向另一个
网站(即一个href),在这种情况下,当调用链接别名时,我使用header方法将
重定向到该页面。
到目前为止,这个脚本一直很好用,但我最近有一个
的客户在php4.2.2下运行它,而getimagesize需要大约。
160秒执行。
任何人都可以想到一种不同的方式来判断一个远程文件是否是一个
图像?而且,有没有其他人在运行php4.2.2时经历过这种行为
与getimagesize?
非常感谢帮助。
谢谢,
Esoos
redirect_to)== 0)
header(" Location:
redirect_to");
else
include("
redirect_to");
使用getimagesize()确定
中指定的链接是否/ p>
I''ve written a link aliasing script that allows users to rewrite urls
on their web pages. The crux of the script is the following:
if(getimagesize($redirect_to) == 0)
header("Location: $redirect_to");
else
include("$redirect_to");
Which uses getimagesize() to determine if the link specified in
$redirect_to points to an image (i.e img src) in which case it should
include the image in the page, or if the link points to another
website (i.e. a href), in which case I use the header method to
redirect to that page when the link alias is called.
So far this script has been working great, but I recently had a
customer run it under php4.2.2 and the getimagesize is taking approx.
160 seconds to execute.
Can anyone think of a different way to tell if a remote file is an
image? And also, has anyone else experienced this kind of behavior
with getimagesize when running php4.2.2?
Assistance is really appreciated.
Thanks,
Esoos
redirect_to) == 0)
header("Location:
redirect_to");
else
include("
redirect_to");
Which uses getimagesize() to determine if the link specified in
这篇关于如何判断远程文件是否为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!