browser upload restrict file types

user clicks on browser upload button, the explorer window appears.   is there any way I can only show certain file types in this window, jpg, png etc? , like what you see in Photoshop?
 
PS I know I can check via the cf file upload tag for file types and I do this, but I just  want to add another layer to this before the user get to this stage.

Thanks to any one that can help with this. :)    
LVL 12
pigmentartsAsked:
Who is Participating?
 
James RodgersConnect With a Mentor Web Applications DeveloperCommented:
in teh cffiule ther is an option that will allow only certain mime types to be processed, the attribute is allow and teh values are a comma separated list.
i use this as a mimetype reference
http://www.utoronto.ca/webdocs/HTMLdocs/Book/Book-3ed/appb/mimetype.html
0
 
siva_sivaConnect With a Mentor Commented:
Impossible in web languages..

You can restrict when upload the file.

Go through the following url,
http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-p35.htm#wp3540091

In this you give accept="image/jpg,image/gif,image/png"...
0
 
pigmentartsAuthor Commented:
i was expecting that answer to be honest, i was praying it was not going to be the case, o well back to the drawing board. thanks again hows.  

PS
accept=image/jpg etc  is what i am already doing that fine, i just wanted to add more to the system.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
James RodgersWeb Applications DeveloperCommented:
i do it ujsing js to check that teh file ext is allowed
here is a regex sample - i get it from a table where we specify teh file extesions and mime types that we allow for uploading
var sValidExt=/.doc$|.gif$|.html$|.jpe$|.jpeg$|.jpg$|.mdb$|.mov$|.mp3$|.mpg$|.pdf$|.pjpeg$|.ppt$|.wav$|.xls$|.zip$/;

and teh test routine
if(frmUploadFile['fUploadEN'+x].value && !sValidExt.test(frmUploadFile['fUploadEN'+x].value)){
                  frmUploadFile['fUploadEN'+x].style.backgroundColor='red';
                  if(!strErr){
                        objFocus=frmUploadFile['fUploadEN'+x]
                  }
                  strErr+="Invalid file type detected! Items marked in red cannot be uploaded.\n";
            }
0
 
pigmentartsAuthor Commented:
Jester_48, in a different way this sounds like what i am after, but do you know if javascript would be able to tell the difference between jpeg and pjepg image files as CF allow file types when uploading via FireFox  does not.
0
 
James RodgersWeb Applications DeveloperCommented:
no, its just an extention read not a mime type check and a pjpeg can have an extention of .jpg
the code is more for preventing people from uploading a file ending in a specific extention, like .exe etc. before it gets processed by teh cfm page, just an added validation
0
 
pigmentartsAuthor Commented:
thanks, on another note can i check for a mime type in cf?
0
 
pigmentartsAuthor Commented:
thanks Jester
0
 
James RodgersWeb Applications DeveloperCommented:
glad i could help

thanks for the points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.