Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cffile:upload - accept - problem

Engaged ,
Nov 02, 2008 Nov 02, 2008

Greetings,

My desire is to restrict file uploads to .doc / .pdf / .xls documents.
All seems to be working fine when I upload either .doc or .pdf documents.
However, when I attempt a .xls upload, I get the error message displayed in
my code section <cfcatch></cfcatch> below . I understand what the error
message is indicating, but do not understand why.

I have tried both application/msexcel - and - application/ms-excel and have
received the same error. So perhaps I have the wrong syntax for the excel
component.

Does someone know the correct syntax to use for the excel component?

Is there something else I need to be doing regarding excel files?

Also does someone have a work around for the new microsoft extensions?

Example: docx, xlsx

Thanks in advance for insight to this.

Leonard

- - - My code below - - -

<cftry>

<cffile
action="upload"
destination="C:\path\to\the\folder"
filefield="upload_doc"
nameconflict="overwrite"
accept="application/msword, application/pdf, application/ms-excel">

<cfcatch type="application">

Type - Application

Message - The MIME type of the uploaded file application/vnd.ms-excel was not accepted by the server.

Detail - Only files of type application/msword, application/pdf, application/ms-excel can be uploaded.
Verify that you are uploading a file of the appropriate type.

</cfcatch>

</cftry>
8.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 02, 2008 Nov 02, 2008
The correct MIME type for Excel files is indeed application/vnd.ms-excel. That is the value you should use in the accept attribute.

Translate
Community Expert ,
Nov 02, 2008 Nov 02, 2008
The correct MIME type for Excel files is indeed application/vnd.ms-excel. That is the value you should use in the accept attribute.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 02, 2008 Nov 02, 2008
BKBK -

Thanks I thought that was the correct syntax.

Now that being established, do you or does anyone else have any
insight as to why the process (see code above) will not allow an
excel file to upload?

Leonard
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 02, 2008 Nov 02, 2008
quote:

Originally posted by: Leonard B
BKBK -

Thanks I thought that was the correct syntax.

Now that being established, do you or does anyone else have any
insight as to why the process (see code above) will not allow an
excel file to upload?

Leonard

Could it be because what you are attempting is different than what BKBK told you was the correct answer?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 02, 2008 Nov 02, 2008
Greetings -

OK I went back and checked my code after BKBK's post and made sure that
all matched as stated and tried again. Now all .xls file types will upload.

Thanks to you all for the assistance.

- - - Also - - -

As for the second part of the question, do any of you know how to get the new
file extension format for excel and word (.docx and .xlsx) to validate through
the process?

Leonard B

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 02, 2008 Nov 02, 2008
bookmark this link for general mime types:
http://www.w3schools.com/media/media_mimeref.asp

for office2007 mime types:
docx -
application/vnd.openxmlformats-officedocument.wordprocessingml.document
potx - application/vnd.openxmlformats-officedocument.presentationml.template
ppsx -
application/vnd.openxmlformats-officedocument.presentationml.slideshow
pptx -
application/vnd.openxmlformats-officedocument.presentationml.presentation
xlsx - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

hth


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 02, 2008 Nov 02, 2008
Azadi,

Thanks for the information, that did the trick.

Leonard
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 01, 2009 May 01, 2009

You can limit what cffile accepts, but how do you limit what the user's browse button input type="file" accepts?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 01, 2009 May 01, 2009
LATEST

The "accept" property of the <input type="file"...> tag.

http://www.blooberry.com/indexdot/html/tagpages/i/inputfile.htm

Accept
[2|3|3.2|4]     [X1|X1.1]     [IE|M|N|O]    
Standards Details:         In all HTML 4.x/XHTML DTDs    
Required? No    
Description:
        This attribute specifies the MIME types that the form processing server         and script should correctly handle. A browser may use this information to         filter out non-conforming files when prompting a user to select files to upload.    
Values:
        Comma-separated list of MIME types


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 02, 2008 Nov 02, 2008
read BKBK's reply carefully:

correct .xls mime type is: application/vnd.ms-excel

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources