There is a config option per profile to limit the extensions of files that can be uploaded, but no setting to limit the extensions of files that can be browsed.

My use case is for WYSIWYG editor integration. The common image directory for calendar events also contains PDF files that have been attached to events, and it makes no sense to allow those to be inserted into the body since very few browsers would display them anyway.

So I'd love to be able to specify a list of file extensions that only those matching files would be displayed as choices to the user in the browse dialog.

Comments

hargobind’s picture

Title: Should be able to filter available files in the browse dialog » Filter files by extension in the browse dialog
Version: 7.x-1.7 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new9.19 KB

I have created a patch to accomplish this. Please review it.

A lot of the code changes were a matter of renaming the existing profile variables from extensions to extensions_upload, and I made sure to add a hook_update_N() to account for this variable name change. Make note that this update introduces a string change to the old config setting "Permitted file extensions", and adds new strings, so translations will have to be updated too.

thalles’s picture

Category: Feature request » Support request

Currently any browser can open a PDF file, so, maybe this don't do more sense

thalles’s picture

Status: Needs review » Fixed
hargobind’s picture

Status: Fixed » Closed (works as designed)

@thalles This issue is bigger than just PDF files. It applies to any kind of file type that an administrator might want to restrict.

However, I don't really feel that this feature is necessary the more I think about it. I don't see any sense in allowing someone to upload certain file types but restricting them to browsing different file types. I think that if you really need to restrict browsing to specific file types, then creating additional IMCE profiles should be sufficient.

thalles’s picture

Thanks @hargobind!

rtnilesh.gupta’s picture

double file extension it is taking any idea how to stop? like salt.php.pdf not to take in drupal 7 webform but it is taking how to alter? por stop or is there any option to rename the extension. before upload or after upload. i need custom module or is there any module?

hargobind’s picture

@rtnilesh.gupta Your question is different than the original issue. Please open a new issue.