Solved

Filter for uploading a file

Posted on 2002-05-07
12
7,479 Views
Last Modified: 2007-11-27
I'm developing a site, and amajor part of the working with that site is uploading files to the site servers.
I have some third party softwares that deals with this uploading things just fine.
BUT in the browser, when the user clicks on the "Browse" button near the file field, he/she gets a browsing window from the operating system, but with filter "All Files (*.*)"  and the combo box shows two more options "Pictures (*.jpg, *.gif)" & "HTML (*.htm, *.html).
How can control those filters? i.e. I want the user to upload only Access files (*.mdb), and I block, by javascript, the optin to upload file that doesn't end with .mdb, but I want the browse window to show him only mdb files?
a simple example to the form upload field is here:

<form action="DocumentNew.asp" ENCTYPE="multipart/form-data" method="POST" name="DocumentNew">
file: <input type="file" name="filename" class="formtext" size="60">
<input type=submit>
</form>
0
Comment
Question by:Zvika
  • 3
  • 3
  • 2
  • +4
12 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 100 total points
Comment Utility
To my knowledge, this can't be done.

I have checked the MSDN reference for the input type="file" tag, and there is nothing there that suggests that the filters can be set in any way.

To accomplish this functionality, you would have to build your own file selector. That sounds like a little too much work for this little detail, though...

It looks like you have to educate your users instead. Add a text explaining what is expected from them.
0
 
LVL 5

Expert Comment

by:Christian_Wenz
Comment Utility
some browsers accept the accept attribute:

<input type="file" accept="text/*">

Now, in the pull-down only files with the MIME-type text/* (text/xml, text/plain, text/html, ...) are accepted. However this is not bullet-proof. And there is no other way :-(
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
I concure, it cannot be controled.  If you try Netscape, the default is HTML files.
0
 
LVL 1

Expert Comment

by:giladBoker
Comment Utility
when u submit the form make on submit to go to this function.

<script name=javascript>
function checkFile(filename)
{
  var str=new String(filename)
  now check on the letters after the dot //.txt
  if its diffrent the txt or text then make
   {
   alert("please choose a text file")
   return
   }
  document.form.submit();
}
</script>

use the right method or the splice method in javascript
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
giladBoker, "and I block, by javascript, the option to upload file that doesn't end with .mdb, but I want the browse window to show him only mdb files?"

RTFQ goof.
0
 
LVL 4

Author Comment

by:Zvika
Comment Utility
As there is no solution to my question, I'd like to delete it. any objectors? (I'd be reeeeeeeeeeaaly glad if someone will come up with a solution and will take those point with an A grade :)))
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 4

Author Comment

by:Zvika
Comment Utility
I have a new question relatded to this one, for a 200 points, about file types when DOWNLOADING a file (rather then uploading which is the topic of these question)
http://www.experts-exchange.com/asp/Q.20298636.html
0
 
LVL 4

Author Comment

by:Zvika
Comment Utility
I have a new question relatded to this one, for a 200 points, about file types when DOWNLOADING a file (rather then uploading which is the topic of these question)
http://www.experts-exchange.com/asp/Q.20298636.html
0
 
LVL 5

Expert Comment

by:Christian_Wenz
Comment Utility
well, experts showed you that there is no solution, however this IMO does not justify the deletion of a question. But I am sure customer care will be able to resolve this matter.
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
This Q has been asked before... a simple search would have saved you the points.

As for deleting the Q, a "can't be done..." answer may not be what you wanted to hear, but it is still an answer...
0
 
LVL 6

Expert Comment

by:Mindphaser
Comment Utility
Thanks for all your help everybody. It is good to see that things can be handled in mannerly way in EE. Zvika asked me for help and I tried to explain to him that "Not possible" is an answer sometimes. We agreed to reduce the points to 100 since the 200 points might be a little bit too high for that result. I will refund Zvika's remaining points and he will accept GreenGhost's comment (who was the first to point out the answer) as an answer.

I hope everybody will agree with that decision.

** Mindphaser - Community Support Moderator **
0
 

Expert Comment

by:shaikamjad_ce
Comment Utility
Only by using Javascript we can filter File types at the client side level
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now