Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropzonejs without Form

Is there any way to use Dropzone js without using Form. I want to use like following.But in this way image preview is not showing.

    <div class="dropzone" id="dropzoneForm">
      <div class="fallback">
       <input name="file" type="file" multiple/>
      </div>
    </div>
like image 611
setu Avatar asked Mar 25 '16 18:03

setu


1 Answers

Read more through in the docs and it will explain many problems people faces these days.. Anyways Here is the solution to your problem:

<!DOCTYPE html>
<html lang="en">

  <head>
    <link rel="stylesheet" href="css/basic.css" />
    <link rel="stylesheet" href="css/dropzone.css" />
    <script src="dropzone.min.js"></script>
    <script>
      var myDropzone = new Dropzone("div#myId", {
        url: "/file/post"
      });
      $("div#myId").dropzone({
        url: "/file/post"
      });

    </script>
  </head>

  <body>
    <div id="myId" class="fallback dropzone">
      <input name="file" type="file" multiple />
    </div>
  </body>

What im doing here is giving the div a url to link to so you dont have to use a form!

like image 87
amanuel2 Avatar answered Sep 19 '22 13:09

amanuel2