SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    960
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    File Types issue

    Hai,

    i am using a php script to upload files.

    i have 2 questions.

    PHP Code:
    "image/jpeg" && 
    $_FILES['file']['type'] != "image/pjpeg"
    Question 1.
    What is the diffrent between "image/jpeg" and "image/pjpeg" since bought point .jpg ?

    Qustion 2.

    Can you please list the "Image/????" formats for

    png -
    doc -
    rtf -
    zip -
    txt -
    pdf -

    Please.

  2. #2
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    960
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hai,

    thank you ,

    i foud it while google

    http://unhinfo.unh.edu/NIS/Courses/P...ime-types.html

    but i need to no the diffrents between "image/jpeg" and "image/pjpeg"

  3. #3
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    A google search can easily find answers to both these questions. Here are lists of mime-types for different file types (the "image/???" thing is called a mime-type).

    pjpeg is "progressive jpeg", as I found here.

  4. #4
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You know, it's really unfortunate that the PHP devs included the $_FILES['file']['type'] variable at all. Why? Because it's completely user-supplied and thus 100% untrustworthy. I could easily upload virus.exe and any script that validates based on $_FILES['file']['type'] will happily accept it because I could make it appear to be "image/jpeg" or anything else I want.

    Better is to check the file's extension, and in the case of images (assuming the extension is a "good one") run the file through getimagesize and check that a) the file is an image (getimagesize will return FALSE if it is not), and b) the file is an image type that you want to accept (GIF, JPEG, PNG, etc). If you're accepting non-image files, you just have to rely upon the extension and hope your users are not stupid enough to change virus.doc to virus.exe and run it.
    PHP questions? RTFM
    MySQL questions? RTFM

  5. #5
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    There is no differance between "image/jpeg" and "image/pjpeg". image/pjpeg is what IE sends because it is stupid.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  6. #6
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    960
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raffles View Post
    A google search can easily find answers to both these questions. Here are lists of mime-types for different file types (the "image/???" thing is called a mime-type).

    pjpeg is "progressive jpeg", as I found here.
    First i did not notice your post Raffles,
    Thank you for the links.

  7. #7
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    960
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks other for commenting.


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
  •