[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

browser upload restrict file types

Posted on 2007-10-04
9
Medium Priority
?
6,541 Views
Last Modified: 2013-12-24
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. :)    
0
Comment
Question by:pigmentarts
  • 4
  • 4
9 Comments
 
LVL 5

Assisted Solution

by:siva_siva
siva_siva earned 400 total points
ID: 20013281
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
 
LVL 12

Author Comment

by:pigmentarts
ID: 20013310
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
 
LVL 25

Expert Comment

by:James Rodgers
ID: 20013624
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 12

Author Comment

by:pigmentarts
ID: 20014362
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
 
LVL 25

Expert Comment

by:James Rodgers
ID: 20014530
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
 
LVL 12

Author Comment

by:pigmentarts
ID: 20017480
thanks, on another note can i check for a mime type in cf?
0
 
LVL 25

Accepted Solution

by:
James Rodgers earned 1600 total points
ID: 20017565
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
 
LVL 12

Author Comment

by:pigmentarts
ID: 20021180
thanks Jester
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 20021202
glad i could help

thanks for the points
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
What You Need to Know when Searching for a Webhost Provider
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

830 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