Why doesn't accept work in file upload controls?

Discussion in 'HTML' started by Andrea Desole, Aug 30, 2005.

  1. I'm trying to implement a file upload to upload only xml files. I tried
    accept="text/xml", but that doesn't seem to work, with both Firefox and
    IE (which is the browser I am writing the application for). The only
    information I found tells me that browsers usually disregard the accept
    attribute, for a reason that I absolutely can't understand. Accept is
    part of HTML, and there is no reason for me not to consider it. Also,
    specifying what files to show in an open dialog looks to me a perfectly
    normal thing to do.
    Can anyone explain this strange behavior, and if there is a solution for
    that?
    Thanks

    Andrea
     
    Andrea Desole, Aug 30, 2005
    #1
    1. Advertising

  2. Andrea Desole <> wrote:

    > I'm trying to implement a file upload to upload only xml files.


    You can't, in practice. See http://www.cs.tut.fi/~jkorpela/forms/file.html
    for details.

    > I tried
    > accept="text/xml", but that doesn't seem to work,


    Indeed. Besides, on the theoretical side, if it worked it would limit input
    to files of media type text/xml, and that's not the only possible media
    type for XML.

    > The only
    > information I found tells me that browsers usually disregard the accept
    > attribute,


    Read "usually" as "always".

    > for a reason that I absolutely can't understand.


    Neither can I, but file input has in general been implemented in an awful
    way. Now that the original specification of file input has become obsolete
    and nothing better has been souped up, browser vendors have a good excuse
    for not improving the situation. Besides, there's always XForms in the
    horizon, and it will remove all the current problems with forms.
    (Horizon = an imaginary horizontal line that draws away as you try to
    approach it.)

    > Also,
    > specifying what files to show in an open dialog looks to me a perfectly
    > normal thing to do.


    Well, in a sense, but most file systems actually have no media type concept
    in the sense that would be relevant here. There's nothing in the file
    system that tells which files are XML files, for example. Using the
    filename suffix as an indicator is a very coarse trick and works, at best,
    for a limited set of media types - inconsistently, since there is no
    specification of the correspondence.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
     
    Jukka K. Korpela, Aug 30, 2005
    #2
    1. Advertising

  3. Jukka K. Korpela wrote:
    >
    > You can't, in practice. See http://www.cs.tut.fi/~jkorpela/forms/file.html
    > for details.


    yes, this is one of the pages I found on Google

    >
    >
    > Indeed. Besides, on the theoretical side, if it worked it would limit input
    > to files of media type text/xml, and that's not the only possible media
    > type for XML.


    fair enough. But I could put more types together

    >
    > Neither can I, but file input has in general been implemented in an awful
    > way. Now that the original specification of file input has become obsolete
    > and nothing better has been souped up, browser vendors have a good excuse
    > for not improving the situation. Besides, there's always XForms in the
    > horizon, and it will remove all the current problems with forms.
    > (Horizon = an imaginary horizontal line that draws away as you try to
    > approach it.)


    That sounds promising :)
    Oh well, I guess I can live without filter in the file upload.
    Thanks for the information
     
    Andrea Desole, Aug 31, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    file upload with accept

    Guest, Jun 4, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    888
    Lau Lei Cheong
    Jun 6, 2005
  2. Marina
    Replies:
    2
    Views:
    2,591
    Marina
    Jul 28, 2004
  3. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    922
    Mark Rae
    Dec 21, 2006
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,077
    Smokey Grindel
    Dec 2, 2006
  5. Bjoern
    Replies:
    7
    Views:
    368
    Alan J. Flavell
    Oct 14, 2003
Loading...

Share This Page