Solved

Filter for uploading a file

Posted on 2002-05-07
12
7,481 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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/…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 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

11 Experts available now in Live!

Get 1:1 Help Now