# Allow the binary widget to select certain file types

**URL:** https://discuss.tryton.org/t/allow-the-binary-widget-to-select-certain-file-types/3733
**Category:** Ideas
**Created:** [January 27, 2021, 5:08pm UTC](https://discuss.tryton.org/t/allow-the-binary-widget-to-select-certain-file-types/3733 "2021-01-27T17:08:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![numaelis](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/n/9de053/32.png) [@numaelis](https://discuss.tryton.org/u/numaelis)
#### Post date: [January 27, 2021, 5:08pm UTC](https://discuss.tryton.org/t/allow-the-binary-widget-to-select-certain-file-types/3733/1 "2021-01-27T17:08:02Z")

</div>

Hi guys!

The idea is that you can configure the binary widget to select only certain file types.

maybe in the attributes of the xml:  
field name = “my\_binary\_field” file\_accept = “pdf”

or

file\_accept = “jpg, png”

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 27, 2021, 9:42pm UTC](https://discuss.tryton.org/t/allow-the-binary-widget-to-select-certain-file-types/3733/2 "2021-01-27T21:42:51Z")

</div>

> [@numaelis](#):
>
> maybe in the attributes of the xml

I think it is the proper place as it is more a experience improvement than a validation constraint.

> [@numaelis](#):
>
> field name = “my\_binary\_field” file\_accept = “pdf”
> 
> or
> 
> file\_accept = “jpg, png”

I would simply use the attribute `accept` with the same syntax as [the HTML input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) because [Gtk as similar feature](https://developer.gnome.org/gtk3/stable/GtkFileFilter.html#gtk-file-filter-add-mime-type) (but it will need to distinct also from [pattern](https://developer.gnome.org/gtk3/stable/GtkFileFilter.html#gtk-file-filter-add-pattern).

---

<div class="post-metadata">

### Author: ![numaelis](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/n/9de053/32.png) [@numaelis](https://discuss.tryton.org/u/numaelis)
#### Post date: [January 28, 2021, 7:49pm UTC](https://discuss.tryton.org/t/allow-the-binary-widget-to-select-certain-file-types/3733/3 "2021-01-28T19:49:00Z")

</div>

hi ced!  
okay,  
in html it would be accepted more direct and combinable, using these types:  
[unique\_file\_type\_specifiers](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers)

in the xml of the view form it would be:  
accept = “. pdf, .doc”  
accept = “image / \* ,. pdf”  
accept = “. doc, .docx, application / msword, application / vnd.openxmlformats-officedocument.wordprocessingml.document”

and in gtk would you have to choose a single method internally? MIME type string?  
a loop that checks the string
