The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

FIle Type over HTTP (1 post)

  1. CharlesClarkson
    Posted 6 years ago #

    Is it possible to easily find the file type (or mime type) returned by a url?

    If I am running a script from example.com and I have url on a different domain (i.e. http://www.foo.com/images/snow.pl) which returns a .gif image, how can I determine whether or not it is an image file.

    I'm trying to avoid having to download the file, stick it in a temporary directory, use getimagesize() to get its mime type and then delete the file. That seems like an awful lot of overhead, just to find out if the file displays an image.

    From my research, I am supposed to be able to use getimagesize() to do this remotely, but it seems to be disabled on my (shared) web server.

    I have the GD2 library installed on this server, but I can't find anything that will get me a mime type for an in-memory file. I only need to identify .gif or .jpg files, but an "image or not image" solution might work also.


Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 6 years ago by CharlesClarkson
  • This topic is not resolved
  • WordPress version: 2.8.4