?
Solved

Filter for uploading a file

Posted on 2002-05-07
12
Medium Priority
?
7,489 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
[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
  • 3
  • 3
  • 2
  • +4
12 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 400 total points
ID: 6993700
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
ID: 6993925
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
ID: 6994474
I concure, it cannot be controled.  If you try Netscape, the default is HTML files.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:giladBoker
ID: 6994531
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
ID: 6994561
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
ID: 6998271
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
 
LVL 4

Author Comment

by:Zvika
ID: 6998292
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
ID: 6998293
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
ID: 6998439
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
ID: 6998790
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
ID: 7051649
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
ID: 13635371
Only by using Javascript we can filter File types at the client side level
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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

777 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