Solved

set filter on file type in asp.net or HTML file upload control

Posted on 2010-08-31
19
1,486 Views
Last Modified: 2012-05-10
Hi Experts,

I am writing following code in my asp.net web application.

<input type="file" name="file1" accept="images/*.gif,*.doc" />

The purpose is that when user click on browse button only  gif and doc files should be shown,but this is not working.
Is there any way so that I can set filter on file type in asp.net as we can do in windows application of .net.

Please for this I don't need any freeware control.

If the above said is possible in asp.net file upload control that is also good.

If this is not possible in .net then is it possible in java ?

Thanks
0
Comment
Question by:manujtechno
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 3
  • +1
19 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 33574070
Unfortunately, FileUpload control still have not some Filter property like Open and Save File dialogs in .NET Windows Forms to limit file types. Because of that, you need to write some additional code to be sure that user will upload regular file type.

See: http://www.beansoftware.com/ASP.NET-FAQ/FileUpload-Validation.aspx
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 33574255
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33574752
I think there is a work around, Telerik did it.

It uses Javascript to check the extension, and validate if a valid extension were chose or not.

You cannot force the dialog to filter the files according to extension in web.
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:manujtechno
ID: 33575289
Hi,

Dear Dhaest and vs00saini please go through the attached image.
I do not want to put any validation of file type,I want that when user choose browse button only those file should be visible that is set in file filter type in asp.net page.

Dear Inteqam I do not want to use any third party control.
Filter.bmp
0
 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 99 total points
ID: 33575301
I do not want to put any validation of file type,I want that when user choose browse button only those file should be visible that is set in file filter type in asp.net page.

Like I said before: Unfortunately, FileUpload control still have not some Filter property like Open and Save File dialogs in .NET Windows Forms to limit file types. Because of that, you need to write some additional code to be sure that user will upload regular file type.
0
 

Author Comment

by:manujtechno
ID: 33575483
Dhaest,

 the link you have given doing the same thing they are using validation on that.

Please again go through my question
0
 

Author Comment

by:manujtechno
ID: 33575491
without using any validation is it possible or not ?
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33575559
No
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33577021
Yes
possible

only using Flash uploader or a java applet or even an ActiveX, not the standard uploader.
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33582356
ah, it might be a bug in EXEX system.

apparently, I was able to add the last comment even after the question was closed, because i was opening the question before it has been closed.

at the other hand, it might be that somebody asked it to be re-opened, just wanted to let you know.
0
 

Author Comment

by:manujtechno
ID: 33584468
Inteqam can you give me any link doing the same.
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33584615
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33584646
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 33584919
0
 

Author Comment

by:manujtechno
ID: 33585727
So after long discussion We can be agree on one point that without using any third party control ,the requirement said in question can not be fulfill.Because as Inteqam and saini both give me link they are using flash,jquery plugin and so on.
0
 
LVL 7

Accepted Solution

by:
Inteqam earned 200 total points
ID: 33586464
Because HTML standards prohibits this beside many other things (like multi-selecting, styling the browse buttons, and many others).

Using third party would be by the user's authority, and run at the client (FLASH, ACTIVEX and/or Java Applet).

in other words, at its current situation, wherever you see in the internet a file uploader with:
1- Extension Filter
2- Multi File Select

be sure it is a third party.
0
 
LVL 16

Assisted Solution

by:Vikram Singh Saini
Vikram Singh Saini earned 100 total points
ID: 33586946
I too agree with Inteqam.

After all we want our users to give them rich and creative experience with nice technologies. We want their experiences with our website to be memorable. So focus on improvement.


0
 

Author Closing Comment

by:manujtechno
ID: 33587123
Finally Microsoft leave something for RnD and to be depend on third part.
I was satisfy with the discussion with experts.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question