Just spent hours trying to figure out what was causing this problem, but have found a solution. Was not quite sure where to post this, so if this is not the correct place, then simply inform me where it should go for future reference.

I was trying to upload a jpg file, but filedepot gave an error stating that only txt, pdf, xls, doc extensions were allowed.

Initially, I went to:
Home » Administration » Filedepot Settings
where I modified the settings under the "FILE TYPE FILTERING AND EXTENSION MAPPING" section by changing the radio dial to "Exclude" and emptying the "File types to exclude/include" box.

This did not fix the problem.

So, I ended up going to the following:
Home » Administration » Structure » Content types » Filedepot Folder » Manage fields

I then clicked "edit" across from the "Files" Label. On the next page, under the "Allowed file extensions" section, I added the jpg extension.

This fixed the problem.

Hope this helps someone.

CommentFileSizeAuthor
#9 issue_1505108.patch8.92 KBblainelang
#3 Capture.JPG50.89 KBhilldw

Comments

blainelang’s picture

Category: feature » bug

@quinn, thanks I have changed this to a bug. I had attempted to over-ride the default file upload validation but it appears it's not working yet as I need.

blainelang’s picture

Status: Reviewed & tested by the community » Needs work
hilldw’s picture

StatusFileSize
new50.89 KB

I'm running Drupal 7.12 and I made the change per directions above and I'm still unable to upload .docx file.
UPDATE:

If I go through by clicking content, add content, filedepot folder and upload a file, I am able to upload the .docx file

If I go to my websitename/filedepot and select "new file" and then select the same .docx file, I'm unable to upload.

_randy’s picture

This issue stems from the form API file upload validation routine.

I have this issue resolved, however a patch is not ready yet as I need to review with @blainelang.
The issue is inside of filedepot.module in the filedepot_newfile_form function, the declaration for the filedepot_file form element. We need to specify the valid file formats to the upload validator.

My sample code as follows:

$default_filter  = 'jpg doc docx xls xlsx pdf exe ppt pptx';
  $filter = variable_get('filedepot_filetype_filter', $default_filter);
  $form['filedepot_file'] = array(
    '#type' => 'managed_file',
    '#title' => t('Choose a file'),
    '#size' => 22,
    '#upload_validators' => array(
      'file_validate_extensions' => array($filter),
    ),
  );

The other issue is that the filedepot_filetype_filter variable is set in the filedepot admin interface. Currently the way the file extension filter mechanism works for filedepot is to include or exclude certain file extensions. Unfortunately for this approach to work, 2 things need to be done in filedepot.admin.inc.

in the filedepot_admin_settings function, the exclude/include form element needs to be removed. So this section of code needs to be eliminated as the way the filter works is by only allowing the extensions typed in:

 $form['filetype_filter']['filedepot_filter_mode'] = array(
    '#type' => 'radios',
    '#title' => t('Use inclusion or exclusion mode'),
    '#default_value' => variable_get('filedepot_filter_mode', 1),
    '#options' => array(
      '0' => t('Exclude'),
      '1' => t('Include'),
    ),
    '#description' => t('Choose the way Filedepot will filter for allowable file types during upload.<br />Use exclude to allow all but selected extension:mimetypes. Use include if you want to define each file type to allow and all others will be rejected.'),
  );

Next, directly below that segment of code, the filedepot_filetype_filter needs to be updated to this:

$default_filter  = 'jpg doc docx xls xlsx pdf exe ppt pptx';
  $form['filetype_filter']['filedepot_filetype_filter'] = array(
    '#type' => 'textarea',
    '#title' => t('File types to exclude/include'),
    '#cols' => 60,
    '#rows' => 5,
    '#prefix' => '<div style="margin-left:20px">',
    '#suffix' => '</div>',
    '#default_value' => variable_get('filedepot_filetype_filter', $default_filter),
    '#description' => t('Enter the file extension or list of extensions space separated. '),
    '#wysiwyg' => FALSE,
  );

Doing that should allow filedepot to respect the form API and allow uploads of those extensions added to the filter field.

neokoenig’s picture

Subscribing - hopefully this can be merged into the dev branch soon??

daniel wentsch’s picture

@_randy: I tried appying your above code to my installation but had no luck getting it to work. Did the above changes work for you? Could you kindly point out where exactly changes where made?

_randy’s picture

@Daniel

Yes, my changes work for me. Since my current development branch is not in synch with what is in the d.o dev branch, I explained in my post as best I could where to put the changes. Not optimal, I know.

daniel wentsch’s picture

Ok, nevermind. I switched to elfinder in the meantime .

blainelang’s picture

Status: Needs work » Needs review
StatusFileSize
new8.92 KB

Thanks @_randy, I have used your new code with a few changes and cleaned up some other related code (removed the other logic as it was not working but is logic that was in the D6 version)

Attached is a new patch - if anyone can test it, we will get that committed for the next release which should be very soon.

_timpatrick’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Component: Documentation » Code
Assigned: Unassigned » _timpatrick
Status: Needs review » Reviewed & tested by the community

Tested with multiple different file types - adding some new extensions and removing them, and it works as expected

blainelang’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @_timpatrick, I will commit the patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

damatmadeforcom’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta2
Priority: Minor » Major
Status: Closed (fixed) » Active

Still have the problem with the latest file depot install.
I've looked at the code which is patched with blainelang's. So I don't know where to look at.

The selected file C:\fakepath\iSteve.jpg cannot be uploaded.
Only files with the following extensions are allowed: txt, pdf, xls, doc.

_timpatrick’s picture

I just tried with beta2 release (and dev release) to upload a jpg and it worked - in filedepot settings (admin/settings/filedepot), what is the contents of the "File types to allow" field?

_timpatrick’s picture

Status: Postponed (maintainer needs more info) » Active

- are you attempting to upload a new version and not a new upload? If so, then see http://drupal.org/node/1636082 - I am working on a fix

Edit: Patch made (if it is an issue with uploading a new version):
http://drupal.org/node/1636082#comment-6131856

As well, the 7.x branch has been updated

_timpatrick’s picture

Status: Active » Postponed (maintainer needs more info)
_timpatrick’s picture

Status: Active » Closed (fixed)
AdamsRL’s picture

I have this exact problem. I read all the post, but I don't see where this was resolved. Please excuse me if I am incorrect.

I have installed version 7.x-1.0-beta2 on Linux, can you please let me know how I can resolve this problem?