Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added accept attribute to AjaxFlexibleFileUpload #808

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Frameworks/Ajax/Ajax/Components/AjaxFlexibleFileUpload.api
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
<binding name="mimeType"/>
<binding name="clearedFunction"/>
<binding name="clearedAction"/>
<binding name="accept"/>
</wo>
</wodefinitions>
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* this component to be used in or out of a form. The component is fully styleable (including the upload button) and
* supports upload progress and canceling.
*
* @binding accept the attribute specifies the types of files that the server accepts (that can be submitted through a file upload)
* @binding cancelLabel the label for for the cancel button (defaults to "Cancel")
* @binding startingText the text to display when the progress is starting (defaults "Upload Starting...");
* @binding selectFileLabel the label for the select file button (defaults to "Select File...")
Expand Down Expand Up @@ -219,6 +220,9 @@ protected NSArray<String> _ajaxUploadOptions() {
NSMutableArray<String> _options = new NSMutableArray<>("action:'" + uploadUrl() + "'");

// add options
if (canGetValueForBinding("accept")) {
_options.addObject("accept:'"+ valueForBinding("accept") +"'");
}
_options.addObject("data:{" + ajaxUploadData() + "}");
_options.addObject("name:'" + uploadName() + "'");
_options.add("iframeId:'"+ iframeId() +"'");
Expand Down
3 changes: 3 additions & 0 deletions Frameworks/Ajax/Ajax/WebServerResources/ajaxupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@
this._settings = {
// Location of the server-side upload script
action: 'upload.php',
// accept attribute e.g. '.docx,.pdf'
accept: '',
// File upload name
name: 'userfile',
// Select & upload multiple files at once FF3.6+, Chrome 4+
Expand Down Expand Up @@ -343,6 +345,7 @@
var input = document.createElement("input");
input.setAttribute('type', 'file');
input.setAttribute('name', this._settings.name);
input.setAttribute('accept', this._settings.accept);
if(this._settings.multiple) input.setAttribute('multiple', 'multiple');

addStyles(input, {
Expand Down