Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

I think just doing this might be the trick:

/**
 * Implements hook_menu_alter().
 */
function media_menu_alter(&$items) {
  // Add the more permissive list of allowed file extensions to the file/add
  // upload form.
  $items['file/add']['page arguments'][1] = array(
    'file_extensions' => media_variable_get('file_extensions'),
  );
}

Not sure about this vs using a form_alter though.

Dave Reid’s picture

Looking at http://drupalcode.org/project/media.git/commitdiff/453fad5368c86a89c2baa..., it appears we also lost support for media_variable_get('max_filesize') as well.

Dave Reid’s picture

Title: Media allowed extensions not used on file/add/upload » Media allowed file size not used on file/add/upload

This is now fixed for the extension list with http://drupalcode.org/project/media.git/commit/2666215 in 7.x-2.x.

Ralf Eisler’s picture

file/add/upload in 7.x-2.0-unstable5+1-dev still does not match the allowed file extensions from the media browser settings and is only allowing file extensions from file_save_upload().

Dave Reid’s picture

Make sure to update both Media and File entity to their latest versions.

Ralf Eisler’s picture

Okay, I changed File entity from 7.x-2.0-unstable5 to 7.x-2.x-dev.

Under the upload form file/add I still get "Files must be less than 8 MB. Allowed file types: jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp."

Now, the files for a single or a multiple uplodad can be selected and they appear in the upload form. When I click Start upload the upload is indicated with the green upload bar. After the upload seems to be completed, I get the message "Only files with the following extensions are allowed: jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp." –– And the files aren’t uploded.

bensnyder’s picture

I can upload images from a wysiwyg and an image field with media widget, but I cant upload from /file/add. Using latest file_entity and media 2.x devs.

Warning: filesize(): stat failed for public://tulips.jpg in file_save() (line 570 of /var/www/[site]/includes/file.inc)
bensnyder’s picture

FileSize
65 bytes

Dave -- I'm checking apache error logs and drupal's logs but can't find the root of the problem. Do you have any suggestions for testing this? I can't upload anything from file/add.

It's supposed to be adding the image to /sites/default/files/media but it's uploading to /sites/default/files/. Odd...

Only local images are allowed.

bensnyder’s picture

Also, the file never actually gets uploaded.

Dave Reid’s picture

@bensnyder: Did you actually hit 'Submit' on that form after upload? Also, uploading on file/add will only upload to your site's root file directory since you're not uploading as a field which has a configured upload sub-directory.

bensnyder’s picture

Dave -- lol yes I hit submit :)

Here's some new stuff from the event logger:

LOCATION	http://[site]/file/ajax/upload/form-P6FHX3QMI-6fOgcUDczumNxAf_U3B4mbF49-0Kr0woQ
REFERRER	http://[site]/file/add
MESSAGE	The file permissions could not be set on public://lighthouse.jpg.
SEVERITY	error

LOCATION	http://[site]/file/ajax/upload/form-P6FHX3QMI-6fOgcUDczumNxAf_U3B4mbF49-0Kr0woQ
REFERRER	http://[site]/file/add
MESSAGE	Warning: filesize(): stat failed for public://lighthouse.jpg in file_save() (line 570 of /var/www/[site]/includes/file.inc).
SEVERITY	warning

LOCATION	http://[site]/file/add
REFERRER	http://[site]/file/add
MESSAGE	Notice: Undefined property: stdClass::$image_dimensions in file_entity_file_update() (line 63 of /var/www/[site]/sites/all/modules/file_entity/file_entity.file.inc).
SEVERITY	notice
bensnyder’s picture

Here is the contents of http://[site]/file/ajax/upload/form-P6FHX3QMI-6fOgcUDczumNxAf_U3B4mbF49-0Kr0woQ:

[{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"ytdc","theme_token":"M18j0oKfiZDVhFSfkzK6YcM096KJAzOEcX2d6QlDCPw"},"colorbox":{"opacity":"0.85","current":"{current} of {total}","previous":"\u00ab Prev","next":"Next \u00bb","close":"Close","maxWidth":"100%","maxHeight":"100%","fixed":true,"__drupal_alter_by_ref":["default"]},"googleAnalyticsReportsAjaxUrl":"\/google-analytics-reports\/ajax","shadowbox":{"animate":1,"animateFade":1,"animSequence":"wh","auto_enable_all_images":0,
"auto_gallery":0,"autoplayMovies":true,"continuous":0,
"counterLimit":"10","counterType":"default","displayCounter":1,"displayNav":1,"enableKeys":0,"fadeDuration":"0.35",
"handleOversize":"resize","handleUnsupported":"link","initialHeight":160,"initialWidth":320,"language":"en","modal":false,
"overlayColor":"#000","overlayOpacity":"0.85","resizeDuration":"0.35","showMovieControls":1,
"slideshowDelay":"0","viewportPadding":20,"useSizzle":1}},"merge":true},{"command":"insert","method":"replaceWith","selector":null,"data":"\u003Cdiv class=\u0022messages error\u0022\u003E\n\u003Ch2 class=\u0022element-invisible\u0022\u003EError message\u003C\/h2\u003E\nAn unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (100 MB) that this server supports.\u003C\/div\u003E\n","settings":null}]
Dave Reid’s picture

Hrm, I'm thinking that the server permissions are not properly set on your public files directory, ensuring that the web server can actually write to it, if drupal_chmod() is failing (which is where that error comes from). I think we need to move this to a separate issue since the problem isn't actually that we can't upload files, it's that permissions aren't set correctly, which is unrelated to being able to use this form.

bensnyder’s picture

Dave - thanks for the reply. It can't be file system permissions... I know for sure I have that set correctly. I'm doing more digging tonight - I'll post back my findings. Thanks!

bensnyder’s picture

Finally found a [temporary] fix!
http://drupal.org/node/1337684#comment-5241598

Thoughts, anyone?

acbramley’s picture

A similar form_alter hook is required for the file_entity_add_upload_multiple as well, see http://drupal.org/node/1599892#comment-6461000

gmclelland’s picture

  • Dave Reid committed 2666215 on 7.x-3.x
    Issue #1600610: Fixed media allowed extensions not used on file/add/...
joseph.olstad’s picture

Issue summary: View changes
Status: Active » Fixed

Fixed, and issues marked as related have been fixed.

Thanks to @Dave Reid , and others.

Status: Fixed » Closed (fixed)

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

gisle’s picture

Removed contents from spam attachments.