2

I want to restrict the files seen by the Apex (5.1) File Browse to only CSV files. I am scratching my head on this one as when I set the mime type attribute to mime/csv I get all files. I have tried other mime types text/*, image/* they work as intended, I only see files these types of files. When I do upload CSV files Oracle sets the mime_type field in apex_application_temp_files to text/csv so this is internally recognised. I also have the multi-file select option set.

What am I doing wrong? If this is actually is a bug is there a work around?

Thanks

Bob
Oracle 12c DB, Tomcat, Chrome

Bob
  • 37
  • 2
  • 6
  • OK, adding accept=".csv" works(see answers) , but why does using the mimetype as above not work? – Bob Mar 19 '18 at 08:23

2 Answers2

1

Try this:

<!-- (IE 10+, Edge, Chrome, Firefox 42+) -->
<input type="file" accept=".xls,.xlsx" />

Fill the field "Custom Attributes"enter image description here

Reference: Limit file format when using <input type="file">?


If you need to restrict the upload only for one type of files, so, create a constraint in your table that check if the mimetype is of this type.

enter image description here

romeuBraga
  • 2,135
  • 1
  • 8
  • 20
  • OK, first off thanks for taking the time and trouble to write this, although at first I was somewhat worried that you had missed the point, CSV and XLSX are not the same, and in this instance I specifically want to exclude XLSX which exist in the same directories as the CSVs they have spawned. However, using accept=".csv" works, so thanks... I will not be using a constraint on the table I am populating, don't need it. A simple WHERE clause on the select taking data from apex_application_temp_files to insert in mine suffices. – Bob Mar 19 '18 at 08:18
  • 1
    Many thanks, I trusted that you had the necessary knowledge to perform the exchange from .xslx to .csv. – romeuBraga Mar 19 '18 at 14:54
1

Restriction e.g. to Excel (XLSX) Under "Setting" set "File Types" with the following content to restrict file browse to XLSX only. accept=".xls,.xlsx, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel

@See source: https://w3c.github.io/html/sec-forms.html#element-attrdef-input-accept

andreml
  • 11
  • 1