Inconsistent type checking results

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

    Inconsistent type checking results

    (Also posted in dreamweaver forum)

    I have two *.jpg files. They both display perfectly on my local system. I
    have a check on the type of file in my upload where I check the first five
    characters for "image".

    One uploads and the other does not.
    One passes the "image" test and the other has an empty string there, so it
    fails the upload.

    If I copy that one that fails to a location on the server using Dreamweaver
    (outside of my php script) and then try to display it in my web page, it
    displays perfectly.

    Does anyone have a clue?

    Shelly


  • pfrank26@hotmail.com

    #2
    Re: Inconsistent type checking results

    There are two main types of jpg in the system - jpeg and pjpeg. One
    solution is to use the PHP command getimagesize - see
    http://uk2.php.net/manual/en/function.getimagesize.php . The array it
    returns contains the type of image the supplied file is.

    Comment

    • Shelly

      #3
      Re: Inconsistent type checking results


      <pfrank26@hotma il.com> wrote in message
      news:1122211729 .994522.275720@ o13g2000cwo.goo glegroups.com.. .[color=blue]
      > There are two main types of jpg in the system - jpeg and pjpeg. One
      > solution is to use the PHP command getimagesize - see
      > http://uk2.php.net/manual/en/function.getimagesize.php . The array it
      > returns contains the type of image the supplied file is.
      >[/color]

      I'll try that (in a few weeks), but I am not sure I made myself clear to you
      as to what my problem is. Let me clarify.

      I use type=file in the html description of the field with a name of
      name=filename. Then when I check the type from that one of the images is
      "image" for the first five characters of the type, but the other is blank.
      They are both jpg extensions. What I use is $_FILES['filename']['type'],
      the global variable filled in by the file type textbox using the browse
      button supplied.

      Now from reading the documentation it seems to me that getimagesize() is a
      server-side function to get the details on a file that is on the server. I
      do the testing before actually uploading the file. This is standard
      procedure. If the file is not of the proper type, the upload is not done.
      Dos the getimagesize() work on a file on the user's system? I would think
      not because that would allow the server to browse the user's system
      indiscriminatel y, rather than merely looking at the supplied file -- a major
      privacy breach.

      Shelly


      Comment

      • John Dunlop

        #4
        Re: Inconsistent type checking results

        Shelly wrote:
        [color=blue]
        > I have two *.jpg files. They both display perfectly on my local system. I
        > have a check on the type of file in my upload where I check the first five
        > characters for "image".[/color]

        Is that check $_FILES['filename']['type']? As another poster
        suggested, you could use getimagesize() to determine the type;
        or mime_content_ty pe(); or a mixture of all three.
        $_FILES['filename']['type'], if given at all, is from the
        browser, and so you can't rely on it being 100 % accurate.
        [color=blue]
        > One uploads and the other does not.[/color]

        actually doesn't upload? If so, what error is reported?
        [color=blue]
        > One passes the "image" test and the other has an empty string there, so it
        > fails the upload.[/color]

        ...or it uploads but you discard it because of your "image"
        test?
        [color=blue]
        > If I copy that one that fails to a location on the server using Dreamweaver
        > (outside of my php script) and then try to display it in my web page, it
        > displays perfectly.[/color]

        Where are the jpegs, and I can try at my end. (I trust they
        aren't dirty!?)

        --
        Jock

        Comment

        • Shelly

          #5
          Re: Inconsistent type checking results


          "John Dunlop" <usenet+2004@jo hn.dunlop.name> wrote in message
          news:MPG.1d4df8 428a5521b29896f 5@news.ntlworld .com...[color=blue]
          > Shelly wrote:
          >[color=green]
          >> I have two *.jpg files. They both display perfectly on my local system.
          >> I
          >> have a check on the type of file in my upload where I check the first
          >> five
          >> characters for "image".[/color]
          >
          > Is that check $_FILES['filename']['type']? As another poster
          > suggested, you could use getimagesize() to determine the type;
          > or mime_content_ty pe(); or a mixture of all three.
          > $_FILES['filename']['type'], if given at all, is from the
          > browser, and so you can't rely on it being 100 % accurate.[/color]

          Interesting.
          [color=blue][color=green]
          >> One uploads and the other does not.[/color]
          >
          > actually doesn't upload? If so, what error is reported?[/color]

          None. I do checking and report my own message.
          [color=blue][color=green]
          >> One passes the "image" test and the other has an empty string there, so
          >> it
          >> fails the upload.[/color]
          >
          > ...or it uploads but you discard it because of your "image"
          > test?[/color]

          I don't know for sure. I assumed it didn't upload but maybe it did and I
          threw it away. I thought the check was before it actually uploaded.
          [color=blue][color=green]
          >> If I copy that one that fails to a location on the server using
          >> Dreamweaver
          >> (outside of my php script) and then try to display it in my web page, it
          >> displays perfectly.[/color]
          >
          > Where are the jpegs, and I can try at my end. (I trust they
          > aren't dirty!?)[/color]

          Of course not. However, I am away on vacation and so I can't send them now
          as they are on my home computer. Thanks anyway.

          Shelly


          Comment

          Working...