Dropzone js not working without form
16,554
Solution 1
your url parameter is not pointing to any valid php file. I believe your code should be thus
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<link rel="stylesheet" href="css/basic.css" />
<link rel="stylesheet" href="css/dropzone.css"/>
<script src="dropzone.min.js"></script>
<script type="text/javascript">
var myDropzone = new Dropzone("div#myId", { url: "upload.php"}) //according to your forms action
</script>
<body>
<form action="upload.php">
<input type="text">
<div id="myId" class="dropzone"></div>
</form>
</body>
Solution 2
Initiate .ready
event when DOM ready and use like this.
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<link rel="stylesheet" href="css/basic.css" />
<link rel="stylesheet" href="css/dropzone.css"/>
<script src="dropzone.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function()
{
var myDropzone = new Dropzone("div#myId", { url: "file-upload"});
});
</script>
<body>
<form action="upload.php">
<input type="text">
<div id="myId" class="dropzone"></div>
</form>
</body>
</html>
Author by
Admin
Updated on June 14, 2022Comments
-
Admin almost 2 years
How can I use dropzone without using the class in the form.
I basically want to have a
div
inside a form and callclass="dropzone"
in that div. But it doesn't seems to work.Here is my code below:
<!DOCTYPE html> <html lang="en"> <head> <title></title> <link rel="stylesheet" href="css/basic.css" /> <link rel="stylesheet" href="css/dropzone.css"/> <script src="dropzone.min.js"></script> <script type="text/javascript"> var myDropzone = new Dropzone("div#myId", { url: "file-upload"}) </script> <body> <form action="upload.php"> <input type="text"> <div id="myId" class="dropzone"></div> </form> </body> </html>