Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 31st, 2005, 02:43 PM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Input type=file apply a filter??

I am curious to know if anyone can help me out with applying a filter (only show *.doc || All Files) to the browse dialog that appears. I am able to do it successfully with a windowsapplication, but not sure how to do with a webform. Any help would be awesome. thanks

 
Old January 31st, 2005, 02:47 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Unfortunately, you cannot do that. The <input type="file"> control does not provide this functionality.

What you could do is validate the contents of the input box with JavAscript after the user has selected a file. It's not as good as a file filter, but it least it minimizes the chance someone uploads an incorrect document format.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 2nd, 2006, 02:10 AM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Actually there is a way to set filter to "Input Type File" just add below Attribute to your "Input type file" and it will work.

accept="image/gif,image/jpeg"

you can add as many options you want as comma separated values

thanks,
Wajhi

 
Old May 24th, 2006, 04:06 AM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by wajhi
Actually there is a way to set filter to "Input Type File" just add below Attribute to your "Input type file" and it will work.
This doesn't seem to work neither in IE or Moz. MSDN says: There is no functionality implemented for this property unless defined by the author.
http://msdn.microsoft.com/library/de...ies/accept.asp

Any suggestions? Here is my ASPX:
<%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="Upload.FileFilters._Default" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
    <title>Default</title>
</head>
<body>
    <form id="Form1" method="post" runat="server">
        <input type="file" id="file1" accept="video/mpeg">
    </form>
</body>
</html>







Similar Threads
Thread Thread Starter Forum Replies Last Post
input type file design in firefox ragu_nit Javascript 3 August 27th, 2007 02:20 PM
input type="file" grstad Classic ASP Basics 24 January 31st, 2007 07:28 PM
INPUT type=file (Urget Help) surendran PHP How-To 1 April 9th, 2006 12:42 PM
input type file darkhalf Javascript 1 October 29th, 2005 02:17 AM
<input type="File"> - Specify File Type and Path gp_mk Classic ASP Basics 2 August 2nd, 2004 03:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.