Solved

Filter for uploading a file

Posted on 2002-05-07
12
7,488 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 100 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

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 informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 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