473,670 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Upload Files : Set Filter

Hi,

I am using <input type="file"> to upload files in my asp.net application.
I want to set the filter so that user can view only .xls files once he/she clicks the Browse button. Is it possible? How?
--------------------------------
From: vishpala kadam
vi************@ yahoo.com

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>y79+Q8elA0O K+IklkT5lHQ==</Id>
Nov 19 '05 #1
3 1993
There is a html attribute where you can specify the filetypes you want to
allow, but the problem is, that most of the browsers (for example IE!)
ignores this attribute.
so you can't really handle this!
You have to check the file on the server after upload.

regards
b.wurm
"vishpala kadam via .NET 247" <an*******@dotn et247.com> schrieb im
Newsbeitrag news:u4******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

I am using <input type="file"> to upload files in my asp.net application.
I want to set the filter so that user can view only .xls files once he/she
clicks the Browse button. Is it possible? How?
--------------------------------
From: vishpala kadam
vi************@ yahoo.com

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>y79+Q8elA0O K+IklkT5lHQ==</Id>

Nov 19 '05 #2
HI vishpala,
you can try with this type of code
OpenFileDialog fileopen = new OpenFileDialog( );

fileopen.Title = "Select only Excel File ";

fileopen.Filter = "Excel files(*.xls)|*. xls";

void Browse_Click(ob ject sender, EventArgs e)

{

fileopen.ShowDi alog();

}

Alex.

"vishpala kadam via .NET 247" <an*******@dotn et247.com> wrote in message
news:u4******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

I am using <input type="file"> to upload files in my asp.net application.
I want to set the filter so that user can view only .xls files once he/she
clicks the Browse button. Is it possible? How?
--------------------------------
From: vishpala kadam
vi************@ yahoo.com

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>y79+Q8elA0O K+IklkT5lHQ==</Id>

Nov 19 '05 #3
The easiest solution is to allow the user to select what ever file he
wants, but before you actually submit to the server, verify that he has
selected the correct file type. Here is a simple html page that only
allows uploads of certain file types.
<HTML>
<HEAD>
<TITLE>My Upload Page</TITLE></HEAD>
<BODY>
<script language="JavaS cript">
function verifyFile()
{
if(document.fil eUpForm.uploade dFile.value == "") {
alert("Must choose a file first!");
return false;
}
if(document.fil eUpForm.uploade dFile.value.len gth < 5) {
alert("Invalid filename. Must contain proper extension.");
return false;
}
if(document.fil eUpForm.uploade dFile.value.sea rch(
/\.(doc|gif|jpg| jpeg|pdf|txt|xl s)$/
) == -1) {
alert("Invalid filename extension.");
return false;
}
return true;
}
</script>
<H2>Upload File</H2>
<form name="fileUpFor m" method="POST" enctype="multip art/form-data"
action="http://www.mycomp.com/upload/UploadHandler.a spx"
ID="Form1">
File to upload: <input name="uploadedF ile" type="file" size="40"
ID="File1" /><p>
<input type="button" name="submitbut ton" value="Submit"
onClick="if(ver ifyFile()){docu ment.fileUpForm .submit();}"
ID="Button1" />
</form>
</BODY>
</HTML>

The page only allows uploads of files with the following extension:
doc, gif, jpg, jpeg, pdf, txt, and xls. You can modify the list to
allow your file types.

sayed

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3729
by: Amy Kimber | last post by:
Hello all, ok, I have a file upload secton to my site, two pages, one with a form and one that does the uploading.... some files upload fine, other don't an exe of 300k will upload, but a word document of 40k wont and so on, in the php.ini a limit of 2mb is set (I haven't changed it, it's how the file originally as, so it isn't my maths that's gone mad).
3
2664
by: Brian Birtle | last post by:
**** A CHALLENGE TO THE GURUS - refute the statement "It's impossible to build a file upload progress meter using ASP.NET" **** First person to prove me wrong gets "All Time .NET Programming GOD" listing in my address book and (optionally) their name listed on my "news" page of my birtle.com website (listed as "Jane Smith is a Programming GOD") for at least a month. Why not take a moment to read more and possibly boost your ego to all time...
2
1642
by: Kenneth Myhra | last post by:
Hi all, We are trying to make an ISAPI Filter, in .NET by implementing the IHttpModule interface, that will authorize the request for certain binary file types (GET), this is working fine. But we also want it to authorize the upload of binary files (PUT), The problem with the PUT-scenario is that the file is *not* uploaded when its extension *is* mapped up in IIS, by mapped up I mean the Application Mappings displayed when clicking on the...
5
737
by: Neo | last post by:
Hello, I am receiving a file as a binary stream from a C++ Client Application. >From the application, the file is being sent as a "Multipart/form-data". I want to receive this file on the server, for which i am using Request.Inputstream and reading it into a byte array. This is not working as it is coupling the binary content with some Boundary and text such as "Content-Disposition:
3
2596
by: U.C. | last post by:
Hello, My client needs to collect data on a disconnected computer. I am hoping I could store data in Isolated Storage as XML files and expose later to a server (does anyone have experience with Isolated Storage)? The solution I am looking for would be to have a connection string or url in the config file and a button the user could push that would automatically transfer files to server. The big caveat here is that I
0
9796
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
21
34390
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
18
34755
jhardman
by: jhardman | last post by:
Have you ever wanted to upload files through a form and thought, "I'd really like to use ASP, it surely has that capability, but the tutorial I used to learn ASP didn't mention how to do this."? Have you looked around trying to find simple solutions but didn't want to wade through pages of complex code? Have you balked at paying for premade solutions that are probably overkill for your particular project? I'd like to walk you through the...
5
3279
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is _uploadedfiles_xxxx) (php must be allowed to move uploaded files to this folder' - uploadedfiles_xxxx. I typed <?php chmod ('_uploadedfiles_xxxx',640); ?> into notepad and saved it as php in the uploaded_xxxx folder, when I went to test it, the error...
0
8814
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8592
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7419
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6213
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2800
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2042
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.