0

I'm trying to use dropzone.js.

This works:

<form id='imageForm' action="<?php print $website["folder"]; ?>upload.php" class="dropzone" data-maxFiles='1'>
</form>

This does not work:

<form id='imageForm'>
</form>
<script>
$("#imageForm").dropzone({ url: websiteFolder + "upload.php" });
</script>

Nor going with:

<script>
Dropzone.options.imageForm = {
  paramName: "file", // The name that will be used to transfer the file
  maxFilesize: 2, // MB
  accept: function(file, done) {
    if (file.name == "justinbieber.jpg") {
      done("Naha, you don't.");
    }
    else { done(); }
  }
};
</script>

In both latter cases, I get no errors, and no dropzone is created.

I'd think I'm overlooking something obvious. But, what is it?

2 Answers 2

1

Dropzone requires that you have an element that has a class .dropzone . If not you will need to create a custom template with these classes in the link below as per doc:

http://www.dropzonejs.com/#layout

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. but this does not make a difference. If I add a dropzone class, the dropzone is indeed created, but the options declared in Dropzone.options.imageForm still don't 'stick'.
0

Turns out that, when instantiating the dropzone through the class, the programmatic really just didn't work (for me).

Not setting the class and then defining the dropzone programmatically worked. But, also required styling the element set as the dropzone, it defaulting to 0 pixels wide and 0 pixels high.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.