SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Non-Member
    Join Date
    Oct 2008
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_FILES type not working properly

    Hey,

    I'm doing the following:

    PHP Code:
    if ($_FILES['file']['type'] != 'image/jpeg' && $_FILES['file']['type'] != 'image/jpg' && $_FILES['file']['type'] != 'image/png' && $_FILES['file']['type'] != 'image/gif'
    Some jpeg/jpg files don't work for some reason. And others do.

    I'm wondering if there is something I could do about it?

  2. #2
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why don't just print $_FILES['file']['type'] to see what type we've got?
    Along with $_FILES['file']['error'] in case of error.

  3. #3
    Non-Member
    Join Date
    Oct 2008
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do this as well.

    It gives me

    image/jpeg

    No errors (error = 0)

    Which makes no sense, because a jpg/jpeg, mime type is image/jpeg.???

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Do not use _FIILES type instead use getimagesize or exif_imagetype.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it's a matter of some mistake.
    I'd use var_dump() to see if there is no spaces and make some other inspections to see if both strings are identical, not just in browser screen.

    Maybe some other code refuse this file? getimagesize for example


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •