getimagesize() not working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Karl Groves

    getimagesize() not working

    I am working on a personal project and having trouble with getimagesize()

    I have an URL to a file I *know* for a fact exists.

    The url in question is pulling longblob data from the database. This has
    never been a problem for me before. Moreover, in the past, this has worked
    for other similar scripts.

    getimagesize works on every image file I have thrown at it, except these
    which are coming from the database.

    What's weird is that file(), stat(), lstat(), fopen() and so on all return
    FALSE when given the URL (and/or path, where appropriate) of this image.

    Even weirder: file_get_conten ts works fine on it.

    Using getimagesize() on this file does NOT return any errors. Its like the
    info is just empty.

    I've been staring at this thing for hours and I'm just drawing a complete
    blank.

    Got any ideas?



    --
    Karl Groves

  • Alvaro G. Vicario

    #2
    Re: getimagesize() not working

    *** Karl Groves escribió/wrote (Thu, 14 Sep 2006 19:25:15 -0500):
    I have an URL to a file I *know* for a fact exists.
    >
    The url in question is pulling longblob data from the database. This has
    never been a problem for me before. Moreover, in the past, this has worked
    for other similar scripts.
    >
    getimagesize works on every image file I have thrown at it, except these
    which are coming from the database.
    >
    What's weird is that file(), stat(), lstat(), fopen() and so on all return
    FALSE when given the URL (and/or path, where appropriate) of this image.
    >
    Even weirder: file_get_conten ts works fine on it.
    >
    Using getimagesize() on this file does NOT return any errors. Its like the
    info is just empty.
    If I understand correctly, you have a PHP script that fetches data from DB
    and prints it with an image MIME type header.

    If you just feed file_get_conten ts() with the script name, it'll read your
    PHP code and it won't (obviously) find its dimensions since it's not an
    image but a text file.

    You should make file_get_conten ts() load the file through the web server so
    the code gets executed:

    file_get_conten ts('http://example.com/load_picture.ph p?foo=bar');

    The approach, though, does not seem very optimal. You'll be retrieving the
    whole pic from DB just to get its size and then discard it. Also,
    load_picture.ph p won't be using the visitor session data or cookies.

    I've been staring at this thing for hours and I'm just drawing a complete
    blank.
    I suppose you just want to generate the <imgtag. Add two columns to table
    and store width and height when inserting the blob.


    --
    -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
    ++ Mi sitio sobre programación web: http://bits.demogracia.com
    +- Mi web de humor con rayos UVA: http://www.demogracia.com
    --

    Comment

    Working...