Skip to content

Commit

Permalink
Adding the enctype and method now if falling back to default upload.
Browse files Browse the repository at this point in the history
This also improves the fallback form. dropzone#22
  • Loading branch information
enyo committed Feb 6, 2013
1 parent 18b52e0 commit 7f499b6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions downloads/dropzone-amd-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,13 @@ Emitter.prototype.hasListeners = function(event){
fields = o("<div class=\"fallback-elements\"><input type=\"file\" name=\"" + this.options.paramName + "\" multiple=\"multiple\" /><button type=\"submit\">Upload!</button></div>");
if (this.elementTagName !== "FORM") {
fields = o("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"post\"></form>").append(fields);
} else {
if (!this.element.attr("enctype")) {
this.element.attr("enctype", "multipart/form-data");
}
if (!this.element.attr("method")) {
this.element.attr("method", "post");
}
}
return fields;
};
Expand Down
7 changes: 7 additions & 0 deletions downloads/dropzone.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,13 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
fields = o("<div class=\"fallback-elements\"><input type=\"file\" name=\"" + this.options.paramName + "\" multiple=\"multiple\" /><button type=\"submit\">Upload!</button></div>");
if (this.elementTagName !== "FORM") {
fields = o("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"post\"></form>").append(fields);
} else {
if (!this.element.attr("enctype")) {
this.element.attr("enctype", "multipart/form-data");
}
if (!this.element.attr("method")) {
this.element.attr("method", "post");
}
}
return fields;
};
Expand Down
7 changes: 7 additions & 0 deletions lib/dropzone.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/dropzone.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ class Dropzone extends Em
fields = o """<div class="fallback-elements"><input type="file" name="#{@options.paramName}" multiple="multiple" /><button type="submit">Upload!</button></div>"""
if @elementTagName isnt "FORM"
fields = o("""<form action="#{@options.url}" enctype="multipart/form-data" method="post"></form>""").append fields
else
# Make sure that the enctype and method attributes are set properly
@element.attr "enctype", "multipart/form-data" unless @element.attr "enctype"
@element.attr "method", "post" unless @element.attr "method"
fields

setupEventListeners: ->
Expand Down

0 comments on commit 7f499b6

Please sign in to comment.