Forum

Thread tagged as: Problem, Error, Forms

file upload doc docx not accepted

I am using Perch Forms and can successfully upload pdf's. These are going to a folder outside of my root. I get the perch:error "file type not accepted" message when uploading files with extension doc or docx. At one time I also had extension .doc and .docx in my "accept" tag, but upload was still not accepted.
This is from my dev site, but am encountering the same pdf success but doc docx failure on my staging server.

Template:

                <div class="larger_label">
                        <perch:label for="sendfile">Send us a file</perch:label>
                    <perch:input type="file" id="sendfile" accept="pdf doc docx xls xlsx txt" />
                        <perch:error for="sendfile" type="filetype"><span class="error">File type is not accepted.</span>
                        </perch:error>
                </div>

Diagnostics report:

SUMMARY INFORMATION

Perch: 2.8.15, PHP: 5.6.10, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (2.8.15), assets (2.8.15), categories (2.8.15), perch_forms (1.8.3)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', 'perch_members', ); ?>
PERCH_LOGINPATH: /perch
PERCH_PATH: /Applications/MAMP/htdocs/wtowers/perch
PERCH_CORE: /Applications/MAMP/htdocs/wtowers/perch/core
PERCH_RESFILEPATH: /Applications/MAMP/htdocs/wtowers/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
Resource folder writeable: Yes
HTTP_HOST: wtowers.dev
DOCUMENT_ROOT: /Applications/MAMP/htdocs/wtowers
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php

PHP error log:

[10-Nov-2015 17:15:00 UTC] PHP Warning:  include(/Applications/MAMP/htdocs/wtowers/perch/addons/apps/perch_members/runtime.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/wtowers/perch/core/inc/apps.php on line 21
[10-Nov-2015 17:15:00 UTC] PHP Warning:  include(): Failed opening '/Applications/MAMP/htdocs/wtowers/perch/addons/apps/perch_members/runtime.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.6.10/lib/php') in /Applications/MAMP/htdocs/wtowers/perch/core/inc/apps.php on line 21
[10-Nov-2015 17:15:05 UTC] PHP Warning:  include(/Applications/MAMP/htdocs/wtowers/perch/addons/apps/perch_members/runtime.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/wtowers/perch/core/inc/apps.php on line 21
[10-Nov-2015 17:15:05 UTC] PHP Warning:  include(): Failed opening '/Applications/MAMP/htdocs/wtowers/perch/addons/apps/perch_members/runtime.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.6.10/lib/php') in /Applications/MAMP/htdocs/wtowers/perch/core/inc/apps.php on line 21

Here's line 21 from the core/inc/apps file:

<?php
    $apps_list = array();
    include(PERCH_PATH . '/config/apps.php');

    if (PerchUtil::count($apps_list)) {
        foreach($apps_list as $app_id) {
            switch($app_id) {
                case 'content':
                    include(PERCH_PATH.'/core/apps/content/runtime.php');
                    break;

                case 'assets':
                    include(PERCH_PATH.'/core/apps/assets/runtime.php');
                    break;

                case 'categories':
                    include(PERCH_PATH.'/core/apps/categories/runtime.php');
                    break;

                default:
                    if (!include(PERCH_PATH.'/addons/apps/'.$app_id.'/runtime.php')) {
                        PerchUtil::debug('Your config/apps.php contains "'.$app_id.'" but that app is not installed.', 'error');
                    }
                    break;
            }
        }
    }

The mime types seem from filetypes.ini seem right:

[office] 
application/arj
application/excel
application/mspowerpoint
application/msword

...

application/vnd.openxmlformats-officedocument.wordprocessingml.document
application/vnd.openxmlformats-officedocument.wordprocessingml.template
application/wordperfect
application/x-excel
application/x-msexcel

I'm not sure what I am doing wrong. Thoughts? Thank you!

John Rose

John Rose 6 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The accept attribute refers to the headings in the filetypes.ini file rather than the file extensions.

These are some excerpted examples from the filetypes.ini file. Do I then include, for example, "application/msword" in the accept=" " tag? Sorry I didn't include these in the earlier post.

[office] 
application/arj
application/excel
application/mspowerpoint
application/msword

...

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.openxmlformats-officedocument.spreadsheetml.template
application/vnd.openxmlformats-officedocument.wordprocessingml.document
application/vnd.openxmlformats-officedocument.wordprocessingml.template
application/wordperfect
application/x-excel
application/x-msexcel
Drew McLellan

Drew McLellan 2638 points
Perch Support

No, use the group heading, which in this case is office

accept="office"

Thanks so much, Drew. Looking forward to your on-line conference!