Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Junior Member _shady's Avatar
    Join Date
    Mar 2007
    Location
    Atlanta, GA USA
    Posts
    20
    Member #
    14934
    Hey, I'm just trying to create a form that allows uploads of a certain type. Everything I've read so far says that you simply add the 'accept' attribute to your file input tag and then the file dialog will only accept files of that type. Is that not the filter that's in the file dialog? Is there no way to set the file dialog to only show zip files or jpegs? I'm guessing that accept will just not allow other file types to be uploaded but why wouldn't that change the filter on the file dialog to *.zip or *.jpeg?
    Thanks in advance for any advice I get!

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    The actual open file dialog is a Windows (or Mac, or Linux, etc.) control, and is programmed as a part of the browser software. It is not controlled by the HTML in the page, and therefore doesn't filter the files it chooses to display.

  4. #3
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    As far as I know, the only real way to check for a subset of extensions is server-side. The trouble with the [minicode]accept[/minicode] attribute is that the spec says user agents `may' use it to filter out types. The actual hard filtering should be done on your end. This is just a helper that browsers can use to assist the users.

  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    I rely on my server side script to check the file type.

    You could use JS to check, http://javascript.internet.com/forms/upload-filter.html

  6. #5
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    In order to have a form with file upload, you are required to
    use a server-side script. What is the script you are using?
    Is is a PHP script, Perl script, ASP?

    It's within that script that the validation takes place.

    You can do some preliminary validation with Javascripting,
    but of course, that can be bypassed ... that's why server-side
    is important.


  7. #6
    Junior Member _shady's Avatar
    Join Date
    Mar 2007
    Location
    Atlanta, GA USA
    Posts
    20
    Member #
    14934
    I was wantin' something for the people that use it. My 'client' asked if I could set the file filter so the users would have an easier time finding files. I understand the part about using (PHP btw) server-side scripting to validate any uploaded files, I was just wondering about the filter on the file dialog. Thank you very much for your help.

  8. #7
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Yes, there's no such filter on the client-side, with the extra importance that if any limitations set on the client-side are bypassed (which is deadly simple to do), it's easy for a malicious user to execute files on your server.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.


Remove Ads

Posting Permissions

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

Search tags for this page

input accept zip

Click on a term to search for related topics.
All times are GMT -6. The time now is 03:03 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com