Solved

Filter for uploading a file

Posted on 2002-05-07
12
7,484 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to hide hopscotch tour popup page reload? 2 96
is this a cms? 8 67
Pass asp session variable to a js function in an asp script 6 27
edit .asp files 5 31
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

829 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