Posted by Dave Reid on May 25, 2012 at 2:38pm
9 followers
| Project: | Media |
| Version: | 7.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Dave Reid |
| Status: | active |
Issue Summary
Current the list of allowed extensions on file/add/upload are the more restricted set allowed by file_save_upload(). We should alter in the media__file_extensions variable.
Comments
#1
I think just doing this might be the trick:
<?php/**
* 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.
#2
Looking at http://drupalcode.org/project/media.git/commitdiff/453fad5368c86a89c2baa..., it appears we also lost support for media_variable_get('max_filesize') as well.
#3
This is now fixed for the extension list with http://drupalcode.org/project/media.git/commit/2666215 in 7.x-2.x.
#4
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().
#5
Make sure to update both Media and File entity to their latest versions.
#6
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.
#7
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)#8
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...
#9
Also, the file never actually gets uploaded.
#10
@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.
#11
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
#12
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}]
#13
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.
#14
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!
#15
Finally found a [temporary] fix!
http://drupal.org/node/1337684#comment-5241598
Thoughts, anyone?
#16
A similar form_alter hook is required for the file_entity_add_upload_multiple as well, see http://drupal.org/node/1599892#comment-6461000